Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gregorian-calendar-format

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gregorian-calendar-format

format utils for gregorian-calendar

  • 4.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

gregorian-calendar-format


format gregorian-calendar instance

gregorian-calendar-format NPM downloads Build Status Coverage Status Dependency Status node version

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
LetterDate or Time ComponentPresentationExamples
GEra designatorTextAD
yYearYear1996; 96
YWeekYearWeekYear1996; 96
MMonth in yearMonthnumber of M matter. such as: MM:01 MMM:Jan MMMM: January
wWeek in yearNumber27
WWeek in monthNumber2
DDay in yearNumber189
dDay in monthNumber10
FDay of week in monthNumber2
EDay in weekTextnumber of E matter. such as: EEEE: Sunday, EEE: Sun
aAm/pm markerTextPM
HHour in day (0-23)Number0
kHour in day (1-24)Number24
KHour in am/pm (0-11)Number0
hHour in am/pm (1-12)Number12
mMinute in hourNumber30
sSecond in minuteNumber55
SMillisecondNumber978
x/zTime zoneGeneral time zonePacific Standard Time; PST; GMT-08:00
ZTime zoneRFC 822 time zone-0800

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.

Keywords

FAQs

Package last updated on 15 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc