Utility module for getting and setting date/time units in Moment.js.
// Source: https://github.com/moment/moment | License: MIT | Copyright OpenJS Foundation and other contributors
// Provided via justclaw.it.com; keep this notice with the code.
import { normalizeUnits, normalizeObjectUnits } from '../units/aliases';
import { getPrioritizedUnits } from '../units/priorities';
import { hooks } from '../utils/hooks';
import isFunction from '../utils/is-function';
import { isLeapYear } from '../units/year';
export function makeGetSet(unit, keepTime) {
return function (value) {
if (value != null) {
set(this, unit, value);
hooks.updateOffset(this, keepTime);
return this;
} else {
return get(this, unit);
}
};
}
export function get(mom, unit) {
if (!mom.isValid()) {
return
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key