Socket
Socket
Sign inDemoInstall

@gothassos/easepick-datetime

Package Overview
Dependencies
0
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @gothassos/easepick-datetime

DateTime object for easepick.


Version published
Weekly downloads
9
increased by80%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

@easepick/datetime

npm version

This package does not need to be installed if you are using @easepick/bundle.

DateTime library for easepick.

Documentation

https://easepick.com/packages/datetime

DateTime() constructor

Creates a JavaScript DateTime instance that represents a single moment in time.
Using: new DateTime(date, format, lang)

argumenttypedefault valuedescription
dateDate
string
number
nullDate object or date string or number (unix timestamp).
formatstring'YYYY-MM-DD'Required when you provide date argument as string. Must match a string value for proper parsing.
langstring'en-US'Affects month names (MMM, MMMM tokens).

You can omit all arguments and call new DateTime(). This will create a DateTime object represents the current date.

Methods

nameargumentsdescription
getWeek-Returns a week number of date
clone-Returns a copy of date
toJSDate-Returns Date object.
inArray(array, inclusivity)Find DateTime object in passed DateTime array.
isBetween(date1, date2, inclusivity)Check if a DateTime is between two other DateTime.
isBefore(date, unit)Check if a DateTime is before another DateTime. unit are day, month, year.
isSameOrBefore(date, unit)Check if a DateTime is before or the same as another DateTime. unit are day, month.
isAfter(date, unit)Check if a DateTime is after another DateTime.. unit are day, month, year.
isSameOrAfter(date, unit)Check if a DateTime is after or the same as another DateTime. unit are day, month.
isSame(date, unit)Check if a DateTime is the same as another DateTime. unit are day, month.
add(duration, unit)Mutates the original DateTime by adding unit. unit are day, month.
subtract(duration, unit)Mutates the original DateTime by subtracting unit. unit are day, month.
diff(date, unit)Returns diff between two DateTime. unit are day, month.
format(format, lang)Format output. See tokens format for format argument. lang affects month names (MMM, MMMM tokens).

Tokens format

Tokens are case-sensitive.

TokenOutput
Day of MonthD1 2 … 30 31
DD01 02 … 30 31
MonthM1 2 … 11 12
MM01 02 … 11 12
MMMJan Feb … Nov Dec
MMMMJanuary February … November December
YearYY70 71 … 29 30
YYYY1970 1971 … 2029 2030
Hours (24 hour time)H0 1 … 22 23
HH01 02 … 22 23
Minutesm1 2 … 58 59
mm01 02 … 58 59
Secondss1 2 … 58 59
ss01 02 … 58 59

FAQs

Last updated on 27 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc