@keen.io/time-utils
![Known Vulnerabilities](https://snyk.io/test/github/keen/keen/badge.svg?targetFile=packages/charts-utils/package.json)
Set of utilities and helper functions responsible for dates and time conversion.
API
getOffsetFromDate
Extracts UTC offset from provided date.
getOffsetFromDate('2021-03-14T16:00:00+03:00');
formatDate
Formats date based on provided pattern and timezone.
formatDate('2021-03-30T12:00:00+02:00', 'Europe/Warsaw', 'YYYY-MM-DD HH:mm');
convertDate
Converts date based on provided offset in minutes or named timezone. Respects daylight saving time offsets.
convertDate('2021-03-14T16:00:00', 180);
convertDate('2021-03-14T16:00:00', -60);
convertDate('2021-03-14T16:00:00', 'Europe/Warsaw');
setTimezoneOffset
Replaces timezone offset without modifying date.
setTimezoneOffset('2021-03-14T16:00:00-12:00', 'Europe/Warsaw');
getDefaultAbsoluteTime
Creates default date range aligned with Keen API absolute Timeframe
interface.
getDefaultAbsoluteTime();