Skip to content
Snippets Groups Projects
Unverified Commit 4bc58241 authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by GitHub
Browse files

parse time with timezone like we do timestamps (#10146)

parent 581a4c97
Branches
Tags
No related merge requests found
......@@ -58,7 +58,7 @@ export function parseTime(value) {
if (moment.isMoment(value)) {
return value;
} else if (typeof value === "string") {
return moment(value, [
return moment.parseZone(value, [
"HH:mm:SS.sssZZ",
"HH:mm:SS.sss",
"HH:mm:SS.sss",
......
import { parseTimestamp } from "metabase/lib/time";
import { parseTime, parseTimestamp } from "metabase/lib/time";
import moment from "moment";
describe("time", () => {
......@@ -41,4 +41,20 @@ describe("time", () => {
);
});
});
describe("parseTime", () => {
it("parse timezones", () => {
const result = parseTime("01:02:03.456+07:00");
expect(moment.isMoment(result)).toBe(true);
expect(result.format("h:mm A")).toBe("1:02 AM");
});
it("parse time without seconds", () => {
const result = parseTime("01:02");
expect(moment.isMoment(result)).toBe(true);
expect(result.format("h:mm A")).toBe("1:02 AM");
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment