Reference
Constructor Functions
Functions to create Timestamp objects.
Function | Description |
---|---|
timestamp(ts) | Create a new timestamp object |
now() | Create a new timestamp for the current date/time |
Timestamp Methods
Methods for getting and setting parts of a Timestamp object.
Method | Description |
---|---|
copy() | Create a copy of a timestamp object |
year() | Get or set the year |
month() | Get or set the month |
day() | Get or set the day |
hours() | Get or set the hours |
minutes() | Get or set the minutes |
seconds() | Get or set the seconds |
epochSeconds() | Return the seconds since the epoch |
epochMilliseconds() | Return the milliseconds since the epoch |
dateObject() | Return a Date object |
Formatting Methods
Methods for formatting a Timestamp object.
Method | Description |
---|---|
stamp() | Return the Timestamp in ISO8601 format |
toString() | Alias for stamp() for auto-stringification |
date() | Return the formatted date |
time() | Return the formatted time |
weekday() | Return the weekday number |
weekdayName() | Return the weekday name |
monthName() | Return the month name |
kebab() | Return the timestamp in kebab case, e.g. 2024-03-01-11-14-01 |
kebabDate() | Return the date in kebab case, e.g. 2024-03-01 |
kebabTime() | Return the time in kebab case, e.g. 11-14-01 |
kebabDateTime() | Return the date and time in kebab case, e.g. 20240301-111401 |
snake() | Return the timestamp in snake case, e.g. 2024_03_01_11_14_01 |
snakeDate() | Return the date in snake case, e.g. 2024_03_01 |
snakeTime() | Return the time in snake case, e.g. 11_14_01 |
snakeDateTime() | Return the date and time in snake case, e.g. 20240301_111401 |
squish() | Return the date and time squished together e.g. 20240301111401 |
squishDate() | Return the date squished together, e.g. 20240301 |
squishTime() | Return the time squished together, e.g. 111401 |
Adjustment Methods
Methods for adjusting a Timestamp object.
Method | Description |
---|---|
adjust(change) | Adjust the Timestamp |
Comparison Methods
Methods for comparing Timestamps.
Method | Description |
---|---|
compare(ts) | Compare the Timestamp with another one |
equal(ts) | Test if the Timestamp is equal to another one |
before(ts) | Test if the Timestamp is before another one |
after(ts) | Test if the Timestamp is after another one |
notBefore(ts) | Test if the Timestamp is not before another one |
notAfter(ts) | Test if the Timestamp is not after another one |
Utility Functions
Utility function used internally or for your own use.
Function | Description |
---|---|
isTimestamp(ts) | Test if the argument matches a timestamp format |
isDate(date) | Test if the argument is a Date object |
splitTimestamp(ts) | Split a timestamp string into component parts |
unpackDate(date) | Extract the component parts from a Date object |
unpackNow() | Extract the component parts from a Date object for the current date/time |
parseDate(date) | Parse a date string using Date.parse() and unpack |
parseDuration(dur) | Parse a duration string, e.g. 3 months |
singularDurations(dur) | Convert plural durations to singular form, e.g. hours to hour |
joinDate(ts) | Join a Timestamp date into a string |
joinTime(ts) | Join a Timestamp time into a string |
joinTimestamp(ts) | Join a Timestamp into a string |
daysInMonth(month, year) | Returns the number of days in a month |
leapYear(year) | Determine if a year is a leap year |