Skip to content

Commit

Permalink
Merge pull request #36 from jacksonbenete/35-date-to-be-fully-customi…
Browse files Browse the repository at this point in the history
…sable

add custom date object
  • Loading branch information
jacksonbenete authored Feb 12, 2024
2 parents 5f3f42a + 9add36e commit 0c8f1e0
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ let userList = [];
let mailList = [];
let cmdLine_;
let output_;
let serverDate = {day: "", month: "", year: "", reference: ""};

function initDateObject() {
const date = new Date();
let day = serverDatabase.day ? serverDatabase.day : date.getDate();
let month = serverDatabase.month ? serverDatabase.month : date.getMonth() + 1;
let year = serverDatabase.year ? serverDatabase.year : date.getFullYear();
let reference = serverDatabase.reference ? serverDatabase.reference : "(Solar System Standard Time)"
serverDate = {day: day, month: month, year: year, reference: reference}
}

function debugObject( obj ) {
for ( const property in obj ) {
Expand All @@ -22,13 +32,10 @@ function debugObject( obj ) {
*/
function setHeader( msg = "⠀" ) {
// Setting correct header icon and terminal name
const date = new Date();
if ( serverDatabase.year ) {
date.setYear( serverDatabase.year );
}
const promptText = `[${ userDatabase.userName }@${ serverDatabase.terminalID }] # `;

const dateStr = `${ date.getDate() }/${ ( 1 + date.getMonth() ).toString().padStart( 2, "0" ) }/${ 1900 + date.getYear() }`;
initDateObject()
const dateStr = serverDate.day + "/" + serverDate.month + "/" + serverDate.year
const header = `
<img align="left" src="config/network/${ serverDatabase.serverAddress }/${ serverDatabase.iconName }" width="100" height="100" style="padding: 0px 10px 20px 0px">
<h2 style="letter-spacing: 4px">${ serverDatabase.serverName }</h2>
Expand Down Expand Up @@ -282,11 +289,9 @@ system = {

date() {
return new Promise( ( resolve ) => {
const date = new Date();
if ( serverDatabase.year ) {
date.setYear( serverDatabase.year );
}
resolve( String( date ) );
let date = new Date();
let time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds()
resolve( String( serverDate.month + " " + serverDate.day + " " + serverDate.year + " " + time + " " + serverDate.reference ) );
} );
},

Expand Down

0 comments on commit 0c8f1e0

Please sign in to comment.