0ad/binaries/data/mods/public/gui/common/OverlayCounterRealtime.js
elexis 38e06fce7e Rewrite FPS/Realtime/Gametime/Ceasefire counters to use object semantics using class notation, refs #5387.
Rebuild the counters every 250ms instead of every frame and minimize
object creation.

Differential Revision: https://code.wildfiregames.com/D2391
Comments By: Stan
This was SVN commit r23096.
2019-10-27 12:39:28 +00:00

21 lines
495 B
JavaScript

/**
* Shows the current time to the player in their current timezone.
*/
OverlayCounterTypes.prototype.Realtime = class extends OverlayCounter
{
constructor(overlayCounterManager)
{
super(overlayCounterManager);
this.date = new Date();
}
get()
{
this.date.setTime(Date.now());
return this.date.toLocaleTimeString();
}
};
OverlayCounterTypes.prototype.Realtime.prototype.Config = "overlay.realtime";
OverlayCounterTypes.prototype.Realtime.prototype.Hotkey = "realtime.toggle";