Author: ygrego Date: 2015-06-09 15:31:49 +0000 (Tue, 09 Jun 2015) New Revision: 1659 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1659 Log: Refactoring of the class DateUtils in an ES6 class. Modified: oipf/lib/js/utils/DateUtils.js Modified: oipf/lib/js/utils/DateUtils.js =================================================================== --- oipf/lib/js/utils/DateUtils.js 2015-06-09 15:28:47 UTC (rev 1658) +++ oipf/lib/js/utils/DateUtils.js 2015-06-09 15:31:49 UTC (rev 1659) @@ -1,36 +1,36 @@ -/* +/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ -var DateUtils = Class.extend({ - - init: function() { +class DateUtils { + + constructor() { this.date = new Date(); this._yesterday = new Date(this.date.getFullYear(), - this.date.getUTCMonth(), + this.date.getUTCMonth(), this.date.getUTCDate()-1); - }, - - millisecondsToSeconds: function(timeInMilliseconds) { + } + + millisecondsToSeconds(timeInMilliseconds) { return timeInMilliseconds / 1000; - }, - - nowInSeconds: function() { + } + + nowInSeconds() { return this.millisecondsToSeconds(Date.now()); - }, - - secondsToMilliseconds: function(timeInSeconds) { + } + + secondsToMilliseconds(timeInSeconds) { return timeInSeconds * 1000; - }, - - secondsToMinutes: function(timeInSeconds) { + } + + secondsToMinutes(timeInSeconds) { return timeInSeconds / 60; - }, - - yesterday: function() { + } + + yesterday() { return this._yesterday; } - -}); + +}
participants (1)
-
ygregoï¼ users.nuiton.org