Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom date object #36

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading