all files / TypeScript.NET/source/System/Time/ TimeStamp.js

29.55% Statements 13/44
14.29% Branches 4/28
50% Functions 3/6
33.33% Lines 12/36
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                                                                 
/*!
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
(function (factory) {
    Eif (typeof module === 'object' && typeof module.exports === 'object') {
        var v = factory(require, exports); Iif (v !== undefined) module.exports = v;
    }
    else if (typeof define === 'function' && define.amd) {
        define(["require", "exports", "../Types"], factory);
    }
})(function (require, exports) {
    "use strict";
    var Types_1 = require("../Types");
    var TimeStamp = (function () {
        function TimeStamp(year, month, day, hour, minute, second, millisecond, tick) {
            if (day === void 0) { day = 1; }
            if (hour === void 0) { hour = 0; }
            if (minute === void 0) { minute = 0; }
            if (second === void 0) { second = 0; }
            if (millisecond === void 0) { millisecond = 0; }
            if (tick === void 0) { tick = 0; }
            this.year = year;
            this.month = month;
            this.day = day;
            this.hour = hour;
            this.minute = minute;
            this.second = second;
            this.millisecond = millisecond;
            this.tick = tick;
            Object.freeze(this);
        }
        TimeStamp.prototype.toJsDate = function () {
            var _ = this;
            return new Date(_.year, _.month, _.day, _.hour, _.minute, _.second, _.millisecond + _.tick / 10000);
        };
        TimeStamp.from = function (d) {
            if (!(d instanceof Date) && Types_1.Type.hasMember(d, 'toJsDate'))
                d = d.toJsDate();
            if (d instanceof Date) {
                return new TimeStamp(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
            }
            else {
                throw Error('Invalid date type.');
            }
        };
        return TimeStamp;
    }());
    exports.TimeStamp = TimeStamp;
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.default = TimeStamp;
});
//# sourceMappingURL=TimeStamp.js.map