1.1.4 • Published 3 years ago

@jewarner57/easydate v1.1.4

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

npm (scoped) GitHub issues GitHub repo size Coveralls Travis (.com)

Easy Date

Has the default JavaScript Date object left you frustrated and sad? Then Easy Date is here to bury your sadness under another level of abstraction.

How to get started?

EasyDate Docs:

  • Below is a list of EasyDate's methods with examples and tips for using them.

when()

  • Returns a human readable string of when a date will happen in relation to the current date.
const ED = new EasyDate('April 21, 2021')

ED.when('May 20, 2021') -> "29 days from now"
ED.when('April 17, 2021') -> "4 days ago"

format()

  • Create a date format string using our list of valid format codes and send it as an argument to the format method. It will return a formatted date.
const ED = new EasyDate('March 21, 2021, 4:03')

ED.format("%M-%D-%Y") -> "03-21-2021"
ED.format('%W, %B %d, %h:%I') -> 'Sunday, March 21, 4:03'

Valid format codes and their meaning:

CodeMeaning
%YFull Year (2021)
%yShort year (21)
%BFull month name (August)
%bAbrev. month name (Aug)
%MZero padding month number July: (07)
%mMonth number July: (7)
%WFull weekday name (Monday)
%wAbrev. weekday name (Mon)
%aWeekday number Sun: (0)
%DZero padded day of the month (09)
%dDay of the month (9)
%HZero padded hour 5pm: (05)
%hHour (5)
%IZero padded minute 5:07pm: (07)
%iMinute 5:07pm: (7)
%SZero padded seconds 5:07:08pm: (08)
%sSeconds 5:07:08pm: (8)

zeroPadNumber()

  • Takes a number the number as a string preceded with a 0 if it is less than 10.
new EasyDate().zeroPadNumber(9) -> "09"
new EasyDate().zeroPadNumber(23) -> "23"

Accessors

  • Here is a list of accessible date object properties:
NameDescriptionExample
yearGets the full yearED.year -> 2010
yrGets the short yearED.yr -> 10
monthGets the full monthED.month -> July
monGets the short monthED.mon -> Jul
numMonthGets the month numberEd.numMonth -> 7
dayGets the full day nameEd.day -> Tuesday
dyGets the short day nameEd.dy -> Tues
numDayGets the day numberEd.numDay -> 2
domGets the date of the monthEd.dom -> 6
hoursGets the hour of dayEd.hours -> 7
minsGets the current minuteEd.mins -> 30
secsGets the current secondEd.secs -> 10
1.1.1

3 years ago

1.1.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago