-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoment-dt.js
36 lines (29 loc) · 867 Bytes
/
moment-dt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
(function (root, factory) {
/* istanbul ignore next */
if (typeof exports === 'object') {
module.exports = factory(require('moment')); // Node
} else if (typeof define === 'function' && define.amd) {
define('moment-dt', ['moment'], factory); // AMD
} else {
root.moment = factory(root.moment); // Browser
}
}(this, function (moment) {
var VERSION = "1.0.7";
/* istanbul ignore if */
if (!moment.tz) {
throw new Error("Can't find moment-timezone");
}
moment.fn.dt = function () {
return {
ts: this.isValid() ? moment.utc(this).unix() : null,
tz: this.tz() || null
};
};
moment.dt = function (dt) {
dt || (dt = {});
return moment.unix(typeof dt.ts === 'number' ? dt.ts : 'invalid').tz(dt.tz || 'invalid timezone');
};
moment.dt.version = VERSION;
return moment;
}));