moment-timezone-for-local-time
Version:
Get all matching timezones given a local time and a timestamp. Moment.js plugin
24 lines • 1.37 kB
JavaScript
import { forLocalTime as _forLocalTime } from "./moment-timezone-for-local-time";
export function forLocalTime(hour, minute, timestamp) {
if (arguments.length === 0) {
var now = new Date();
return _forLocalTime.call(this, now.getHours(), now.getMinutes(), now.getTime());
}
if (timestamp === undefined || timestamp === null) {
timestamp = Date.now();
}
if (typeof hour !== "number" || 23 < hour || hour < 0) {
throw new TypeError("hour arg must be a number and in [0,23]. You gave " + ((hour === null || hour === void 0 ? void 0 : hour.toString()) || "null or undefined") + ".");
}
if (typeof minute !== "number" || 59 < minute || minute < 0) {
throw new TypeError("minute arg must be a number and in [0,59]. You gave " + ((minute === null || minute === void 0 ? void 0 : minute.toString()) || "null or undefined") + ".");
}
return _forLocalTime.call(this, hour, minute, timestamp.valueOf());
}
export function extend(momentJS) {
if (!(momentJS === null || momentJS === void 0 ? void 0 : momentJS.tz)) {
throw new Error("The given object doesn't have a 'tz' property. Make sure to import moment-timezone before extending momentjs with moment-timezone-for-local-time.");
}
momentJS.tz.forLocalTime = forLocalTime;
}
//# sourceMappingURL=index.js.map