I wrote some small addition to my project to display date and time in game:
But the displayed date (only date) differs from what I have actually set on my PC. https://prnt.sc/wagyh2
Is there something wrong with my coding?
JavaScript:
/*:
* @plugindesc v1.00 adds $gameTime variable to MV project
* @desc v1.00 adds $gameTime variable to MV project allowing to display date, time and day of week
* @author Soulrender
* @help ---
*
*/
var $gameTime = null;
function Game_Time(){
this.initialize.apply(this, arguments);
}
Game_Time.prototype = Object.create(Game_Time);
Game_Time.prototype.constructor = Game_Time;
Game_Time.prototype.initialize = function() {
this._time = this.getTime();
this._date = this.getDate();
this._day = this.getDay();
};
Game_Time.prototype.getTime = function(){
var date = new Date();
var timeStr = date.getHours().padZero(2) + ":" + date.getMinutes().padZero(2);
return timeStr;
}
Game_Time.prototype.getDate = function(){
var date = new Date;
var dateStr = date.getFullYear() + "-" + date.getMonth().padZero(2) + "-" + date.getDay().padZero(2);
return dateStr;
}
Game_Time.prototype.getDay = function(){
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var date = new Date;
var dayStr = days[date.getDay()];
return dayStr;
}
Game_Time.prototype.intToTime = function(seconds)
{
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = Math.round(seconds % 60);
return [h, m > 9 ? m : (h ? '0' + m : m || '0'), s > 9 ? s : '0' + s].filter(Boolean).join(':');
}
$gameTime = new Game_Time();
Is there something wrong with my coding?