Returns base date increased by given number of units of time interval.

Parameters
number (number) Amount to increase by.
part ((DATE_PARTS | DATE_PARTS_PLURALIZED)) Date part.
date (jesterday.Date) Base date.
Returns
jesterday.Date: Base date increased by given unit of time interval.

Creates Date object with all properties set to default values except those found in passed object.

Parameters
date (jesterday.Date) Partially set jesterday date object
Returns
jesterday.Date: jesterday date object with all properties set

Enum for date parts.

DATE_PARTS
Static Members
hour
millisecond
minute
month
second
week
year

DATE_PARTS_PLURALIZED

src/lib/enums.js

Enum for date parts pluralized.

DATE_PARTS_PLURALIZED
Static Members
days
hours
milliseconds
minutes
months
seconds
weeks
years

Returns ending point of given time interval based on passed date.

Parameters
part (DATE_PARTS) Time interval, one of [ second|minute|hour|day|month|year ] .
date (jesterday.Date) Base date.
Returns
jesterday.Date: Ending point of given time interval.
Example
// returns { ..., hours: 19, minutes: 59, seconds: 59, milliseconds: 999 }
endOf('hour', { hours: 19, minutes: 55, seconds: 45 })
// returns { ..., month: 3, day: 31, hours: 23, minutes: 59, seconds: 59, milliseconds: 999 }
endOf('month', { month: 3, day: 20, hours: 5 })

Parses ISO date into jesterday date object.

fromISO(isoDate: string): jesterday.Date
Parameters
isoDate (string) Date in ISO format.
Returns
jesterday.Date: Parsed date.

Converts JavaScript Date into jesterday date.

fromJS(jsDate: Date, timezoneOffset: [type]): jesterday.Date
Parameters
jsDate (Date) JavaScript date.
timezoneOffset ([type]) Optional: Timezone offset to set in created date.
Returns
jesterday.Date: Converted date.

jesterday.Date

src/index.js
jesterday.Date

Type: Object

Properties
year (number) : UTC year
month (number) : UTC month (starting from 1)
day (number) : UTC day
hours (number) : UTC hours
minutes (number) : UTC minutes
seconds (number) : UTC seconds
milliseconds (number) : UTC milliseconds

Returns current date.

Returns
jesterday.Date: Current date.

Returns starting point of given time interval based on passed date.

startOf(part: string, date: jesterday.Date): jesterday.Date
Parameters
part (string) Date part.
date (jesterday.Date) Base date.
Returns
jesterday.Date: Starting point of given time interval.
Example
// returns { ..., hours: 19, minutes: 0, seconds: 0, milliseconds: 0 }
startOf('hour', { hours: 19, minutes: 55, seconds: 45 })
// returns { ..., month: 3, day: 1, hours: 0, minutes: 0, ... }
starOf('month', { month: 3, day: 20, hours: 5 })

Returns base date decreased by given number of units of time interval.

Parameters
number (number) Amount to decrease by.
part ((DATE_PARTS | DATE_PARTS_PLURALIZED)) Time interval.
date (jesterday.Date) Base date.
Returns
jesterday.Date: Base date decreased by given unit of time interval.

Converts jesterday date into JS date.

toJS(date: jesterday.Date): Date
Parameters
date (jesterday.Date) Date to convert.
Returns
Date: Converted date.