vmarcella / date-lib

A library for working with dates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Date-lib

Travis (.com) Codecov GitHub issues

Description

A Date library wrapper that extends the functionality of the built in javascript Date object. It is very lightweight and only relies on built in javascript functionality to wrap the date object.

API

Table of Contents

Time

A Date object wrapper that extends the date functionality

Parameters

  • args ...any

year

Get the full year from the date

Examples
Time('10/10/2019').getFullYear() -> 2019

Returns Number The full year

shortYear

Get the short year from the date

Examples
Time('10/10/2019').getFullYear() -> 19

Returns Number The last two digits of the year

month

Get the month from the current date

Examples
Time('10/10/2019').getMonth() -> October

Returns String Get the full month

shortMonth

Get the month from the current date

Examples
Time('10/10/2019').getMonth() -> Oct

Returns String Get the short month

day

Get the day of the month

Examples
Time('10/10/2019').getFullYear() -> 10

Returns Number The day of the month in the date object

longDay

Get the day of the month

Examples
Time('10/1/2019').hours() -> 01

Returns Number The day of the month in the date object

hours

Get the hours of the current date

Examples
Time().hours() -> 0

Returns Number The hour of the current date

longHours

Get the long hours of the current date

Examples
Time().longHours() -> 00

Returns Number The hour of the current date

minutes

Get the minutes of the current date.

Examples
Time().minutes() -> 0

Returns Number The minutes of the current date

longMinutes

Get the long minutes of the current date.

Examples
Time().longMinutes() -> 00

Returns Number The minutes of the current date

seconds

Get the full year from the date

Examples
Time().getFullYear() -> 2019

Returns Number The full year

longSeconds

Get the day of the month

Examples
Time('10/1/2019').hours() -> 01

Returns Number The day of the month in the date object

format

format a string given a mask to format properties of the time object.

Parameters
  • mask (optional, default '')
Examples
Time('10/1/2019').format('Y-m-D') -> '2019-October-1'

Returns String The formatted string

when

return when the date stored in the time object had occured relative to now.

Examples
Time('10/1/2019').when() -> '2 months ago (if todays month is august)'

Returns String the string containing when the date occurred relative to now.

About

A library for working with dates


Languages

Language:JavaScript 100.0%