4.1.3 • Published 9 years ago
gregorian-calendar-format v4.1.3
gregorian-calendar-format
format gregorian-calendar instance
use on node
var GregorianCalendarFormat = require('gregorian-calendar-format');
var GregorianCalendar = require('gregorian-calendar');
var gregorianCalendar = new GregorianCalendar();
gregorianCalendar.set(2013, GregorianCalendar.JULY, 9);
var df = new GregorianCalendarFormat('yyyy-MM-dd');
console.log(df.format(gregorianCalendar));
df = new GregorianCalendarFormat('yy-MM-dd');
console.log(df.format(gregorianCalendar));
API
Constructor GregorianCalendarFormat(pattern: String, locale: Object)
- pattern: pattern string used to format or parse
such as "yyyy-MM-dd'日'" will parse and format "2013-11-12日" "2013-01-02日". (content inside '' will preserve)
- locale: require('gregorian-calendar-format/locale/en_US') or require('gregorian-calendar-format/locale/zh_CN') specify text when render localize date time string.
String GregorianCalendarFormat.prototype.format(calendar: GregorianCalendar)
format an instance of GregorianCalendar according to pattern
GregorianCalendar GregorianCalendarFormat.prototype.parse(dateString: String, {locale: object})
parse a dateString to an instance of GregorianCalendar according to pattern, it's better to specify calendarLocale, such as
df.parse('2013-11-12', {locale: require('gregorian-calendar/lib/locale/zh_CN'}));
GregorianCalendarFormat GregorianCalendarFormat.getDateTimeInstance(dateStyle, timeStyle, locale)
get a predefine GregorianCalendarFormat instance
- dateStyle: enum of predefined date style, enums:
- en_US:
- GregorianCalendarFormat.Style.FULL presents EEEE, MMMM d, yyyy
- GregorianCalendarFormat.Style.LONG presents MMMM d, yyyy
- GregorianCalendarFormat.Style.MEDIUM presents MMM d, yyyy
- GregorianCalendarFormat.Style.SHORT presents M/d/yy
- zh_CN:
- GregorianCalendarFormat.Style.FULL presents "yyyy'年'M'月'd'日' EEEE"
- GregorianCalendarFormat.Style.LONG presents "yyyy'年'M'月'd'日'"
- GregorianCalendarFormat.Style.MEDIUM presents "yyyy-M-d"
- GregorianCalendarFormat.Style.SHORT presents "yy-M-d"
- timeStyle: enum of predefined date style, enums:
- en_US:
- GregorianCalendarFormat.Style.FULL presents 'h:mm:ss a \'GMT\'Z'
- GregorianCalendarFormat.Style.LONG presents 'h:mm:ss a'
- GregorianCalendarFormat.Style.MEDIUM presents 'h:mm:ss a'
- GregorianCalendarFormat.Style.SHORT presents 'h:mm a'
- zh_CN:
- GregorianCalendarFormat.Style.FULL presents "ahh'时'mm'分'ss'秒' 'GMT'Z"
- GregorianCalendarFormat.Style.LONG presents "ahh'时'mm'分'ss'秒'"
- GregorianCalendarFormat.Style.MEDIUM presents "H:mm:ss"
- GregorianCalendarFormat.Style.SHORT presents "ah:mm"
- locale: require('gregorian-calendar-format/locale/en_US') or require('gregorian-calendar-format/locale/zh_CN') specify text when render localize date time string.
License
gregorian-calendar-format is released under the MIT license.
4.1.3
9 years ago
4.1.2
9 years ago
4.1.1
9 years ago
4.1.0
9 years ago
4.0.4
10 years ago
4.0.3
10 years ago
4.0.2
10 years ago
4.0.1
10 years ago
4.0.0
10 years ago
3.1.0
10 years ago
3.0.1
10 years ago
3.0.0
10 years ago
2.1.1
10 years ago
2.1.0
10 years ago
2.0.2
11 years ago
2.0.1
11 years ago
2.0.0
11 years ago
1.0.4
11 years ago
1.0.3
11 years ago
1.0.2
11 years ago
1.0.1
11 years ago
1.0.0
11 years ago