We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 054e54d commit 15d9368Copy full SHA for 15d9368
background/util.js
@@ -123,18 +123,15 @@ util.ajax.next = function() {
123
* @return {Number}
124
*/
125
util.relativeToTimestamp = function(str) {
126
- var s = str.trim().split(' ');
127
- var n = parseInt(s[0], 10);
+ var r = /(\d+)\s+(second|minute|hour|day)s?/.exec(str);
+ if (!r) { return null; }
128
+ var n = parseInt(r[1], 10);
129
var multiplier = {
130
second: 1,
- seconds: 1,
131
minute: 60,
132
- minutes: 60,
133
hour: 3600,
134
- hours: 3600,
135
day: 86400,
136
- days: 86400,
137
- }[s[1]];
+ }[r[2]];
138
return Date.now() - n * multiplier * 1000;
139
};
140
0 commit comments