1.0.1 • Published 3 years ago

@chaonengtan/few2.1-datelibrary v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

npm (scoped) NPM GitHub code size in bytes GitHub issues

DateLibrary

Adds easy ways to access properties of the Date object Adds format function to return a customized formatted date string Adds when function to return in how long is the target date compared to today

Getters: .year (returns the full year ie. 2021) .yr (returns the shortened year ie. 21) .month (returns the month in text ie. April) .mon (returns the month in shortened text ie. Apr) .week (returns the weekday in text ie. Wednesday) .wk (returns the weekday in shortened text ie. Wed) .dates (returns the padded date ie. 04) .date (returns the date ie. 4) .hours (returns the padded hour ie. 06) .hr (returns the hour ie. 6) .minutes (returns the padded minutes ie. 01) .mins (returns the minutes ie. 1) .seconds (returns the padded seconds ie. 07) .secs (returns the seconds ie. 7)

Functions: .format(format) (returns a customized formatted date string using the following key and getters above: 'Y':this.year, 'y':this.yr, 'M':this.month, 'm':this.mon, 'D':this.dates, 'd':this.date, 'H':this.hours, 'h':this.hr, 'I':this.minutes, 'i':this.mins, 'S':this.seconds, 's':this.secs ) .when() (returns in how long is the target date compared to today in the largest magnitude if const targetDate = Date(2022, 5, 15) if today is Date(2021, 4, 14) today.when() //returns 1years )