Sugar.js日期:相当于moment.months()?获取所有月份的列表

时间:2014-04-09 18:01:32

标签: sugar.js

相当于moment.months()和moment.weekdaysShort()?

moment.months()
["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

moment.weekdaysShort()
["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

到目前为止,我最喜欢的是这个,是不是有更清洁的版本?

Date.getLocale().months
["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", 
"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]

1 个答案:

答案 0 :(得分:0)

现在,我在CS中这样做:

(m[0].toUpperCase() + m[1..-1] for m in Date.getLocale().months[0..11])