Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
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
9 changes: 5 additions & 4 deletions models/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const _ = require('underscore');
const moment = require('moment');

const defaultTimeFormat = '[%sign][%days>d ][%hours>h ][%minutes>m ][%seconds>s]';
const mappings = ['complete', 'sign', 'days', 'hours', 'minutes', 'seconds'];
const regex = /^(?:([-])\s*)?(?:(\d+)d\s*)?(?:(\d+)h\s*)?(?:(\d+)m\s*)?(?:(\d+)s\s*)?$/;
const mappings = ['complete', 'sign', 'weeks', 'days', 'hours', 'minutes', 'seconds'];
const regex = /^(?:([-])\s*)?(?:(\d+)w\s*)?(?:(\d+)d\s*)?(?:(\d+)h\s*)?(?:(\d+)m\s*)?(?:(\d+)s\s*)?$/;
const conditionalRegex = /(\[\%([^\>\]]*)\>([^\]]*)\])/ig;
const defaultRegex = /(\[\%([^\]]*)\])/ig;

Expand Down Expand Up @@ -83,7 +83,8 @@ class time {
return (parsed.sign ? -1 : 1) * (parseInt(parsed.seconds)
+ (parseInt(parsed.minutes) * 60)
+ (parseInt(parsed.hours) * 60 * 60)
+ (parseInt(parsed.days) * hoursPerDay * 60 * 60));
+ (parseInt(parsed.days) * hoursPerDay * 60 * 60)
+ (parseInt(parsed.weeks) * 5 * hoursPerDay * 60 * 60));
}

/**
Expand Down Expand Up @@ -137,4 +138,4 @@ class time {
}
}

module.exports = time;
module.exports = time;