Fix broken Helper.durationToSeconds, as it doesn't handle weeks
This commit is contained in:
parent
74551f58d7
commit
afcece17dd
|
@ -243,6 +243,18 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
const day = 86400;
|
const day = 86400;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* number of seconds in a week
|
||||||
|
*
|
||||||
|
* = 60 * 60 * 24 * 7 seconds
|
||||||
|
*
|
||||||
|
* @name Helper.week
|
||||||
|
* @private
|
||||||
|
* @enum {number}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
const week = 604800;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* number of seconds in a month (30 days, an approximation)
|
* number of seconds in a month (30 days, an approximation)
|
||||||
*
|
*
|
||||||
|
@ -326,7 +338,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
me.durationToSeconds = function(duration)
|
me.durationToSeconds = function(duration)
|
||||||
{
|
{
|
||||||
let pieces = duration.split(/\d+/),
|
let pieces = duration.split(/(\D+)/),
|
||||||
factor = pieces[0] || 0,
|
factor = pieces[0] || 0,
|
||||||
timespan = pieces[1] || pieces[0];
|
timespan = pieces[1] || pieces[0];
|
||||||
switch (timespan)
|
switch (timespan)
|
||||||
|
@ -337,6 +349,8 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
return factor * hour;
|
return factor * hour;
|
||||||
case 'day':
|
case 'day':
|
||||||
return factor * day;
|
return factor * day;
|
||||||
|
case 'week':
|
||||||
|
return factor * week;
|
||||||
case 'month':
|
case 'month':
|
||||||
return factor * month;
|
return factor * month;
|
||||||
case 'year':
|
case 'year':
|
||||||
|
|
Loading…
Reference in New Issue