Utility module for transforming between Unix timestamp integers and formatted date strings. Supports various date/time formats and localization options.
- Source
Methods
(inner) date(timestamp) → {string}
Formats Unix timestamp to ISO date string (YYYY-MM-DD)
Name | Type | Description |
---|---|---|
timestamp | integer | Unix timestamp in seconds |
- Source
ISO date string
- Type:
- string
(inner) dateString(params) → {string}
Formats a Unix timestamp into a localized date string. If not explicit in the param the language for the locale will be taken from the mapp.user object or fallback to the default format.
Name | Type | Description |
---|---|---|
params | Object | Input parameters |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
params.value | number | Unix timestamp in seconds | ||
params.newValue | number | <optional> | Updated timestamp value (takes precedence over value) | |
params.locale | string | <optional> | en-GB | Locale identifier |
params.options | Intl. | <optional> | Formatting options |
- Source
Formatted date string
- Type:
- string
(inner) dateToUnixEpoch(dateStropt) → {number}
Converts a date string to Unix timestamp. The current data will be used if no dateStr is provided.
Name | Type | Attributes | Description |
---|---|---|---|
dateStr | string | <optional> | Date string parseable by JavaScript Date |
- Source
If date string is invalid
- Type
- Error
Unix timestamp in seconds
- Type:
- number
(inner) datetime(timestamp) → {string}
Formats Unix timestamp to ISO datetime string (YYYY-MM-DDThh:mm:ss)
Name | Type | Description |
---|---|---|
timestamp | integer | Unix timestamp in seconds |
- Source
ISO datetime string without timezone
- Type:
- string