开发者

Custom date units for javascript

开发者 https://www.devze.com 2023-04-07 21:05 出处:网络
I\'m working on a javascript app that does a lot of Date arithmetic, and for convenience (and readable code), I\'ve found it useful to create some constants that I load into each page:

I'm working on a javascript app that does a lot of Date arithmetic, and for convenience (and readable code), I've found it useful to create some constants that I load into each page:

var oneSecond = 1000;
var oneMinute = 60*oneSecond;
var oneHour   = 60*oneMinute;
var oneDay    = 24*oneHour;
var oneWeek   = 7*oneDay;

I'm going through a code refactor (down with cruft!), and it occurs to me that I can't be the first one who needed constants like these.

Is there an canonical javascript library th开发者_JAVA百科at provides these (or something comparable) so I can just use it and be nicer to my readers?


I think you're looking for datejs:

http://www.datejs.com/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号