Changeset 28459

Show
Ignore:
Timestamp:
01/15/09 23:45:05 (4 years ago)
Author:
drry
Message:
  • (duration) ミリ秒とマイナスに対応しました。
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/jautopagerize.user.js

    r28429 r28459  
    790790function duration (str) { 
    791791        var ret = 0, map = { 
    792                 sec : 1, min : 60, hour : 3600, day : 86400, week : 604800, month : 2592000, year : 31536000 
     792                sec : 1000, min : 60000, hour : 3600000, day : 86400000, week : 604800000, month : 2592000000, year : 31536000000 
    793793        }; 
    794         str.replace(/(\d+)\s*(msec|sec|min|hour|day|week|month|year)s?/g, function (_, num, unit) { 
    795                 ret += +num * map[unit]; 
     794        str.replace(/([-+]?\d+)\s*((?:m(?:illi)?)?sec|min|hour|day|week|month|year|)/g, function (_, num, unit) { 
     795                ret += +num * (map[unit] || 1); 
    796796        }); 
    797         return ret * 1000; 
     797        return ret; 
    798798} 
    799799