Skip to content
Snippets Groups Projects
Commit 46162d7d authored by Benyounes Moumni's avatar Benyounes Moumni
Browse files

parse +-hhmm timzones

parent e60f653e
Branches
Tags
No related merge requests found
import moment from "moment";
// only attempt to parse the timezone if we're sure we have one (either Z or ±hh:mm)
// only attempt to parse the timezone if we're sure we have one (either Z or ±hh:mm or +-hhmm)
// moment normally interprets the DD in YYYY-MM-DD as an offset :-/
export function parseTimestamp(value, unit) {
if (moment.isMoment(value)) {
return value;
} else if (typeof value === "string" && /(Z|[+-]\d\d:\d\d)$/.test(value)) {
} else if (typeof value === "string" && /(Z|[+-]\d\d:?\d\d)$/.test(value)) {
return moment.parseZone(value);
} else if (unit === "year") {
// workaround for https://github.com/metabase/metabase/issues/1992
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment