Skip to content

Commit

Permalink
Add 'addSeconds' function to DateUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinze authored and Rinze committed Nov 10, 2015
1 parent f53bc5d commit 6e83892
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions csServerComp/ServerComponents/helpers/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ interface Date {
addDays(days: number): Date;
/** Add a number of minutes */
addMinutes(mins: number): Date;
/** Add a number of seconds */
addSeconds(secs: number): Date;
/** Get the number of days between two dates */
diffDays(date: Date): number;
/** Get the number of hours between two dates */
Expand All @@ -26,6 +28,11 @@ Date.prototype.addMinutes = function(mins: number) {
dat.setMilliseconds(this.getTime() + (mins*60000));
return dat;
};
Date.prototype.addSeconds = function(secs: number) {
var dat = new Date(0);
dat.setMilliseconds(this.getTime() + (secs*1000));
return dat;
};
Date.prototype.diffDays = function(date: Date) {
var diffMs = (this.getTime() - date.getTime()); // milliseconds
return Math.round(diffMs / 86400000);
Expand Down

0 comments on commit 6e83892

Please sign in to comment.