# all files / TypeScript.NET/source/System/Time/ ClockTime.js

64.47% Statements 49/76
38.46% Branches 20/52
70% Functions 7/10
70.15% Lines 47/67

    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
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88

    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    2×
    2×
    5×

    2×

    2×
    2×
    2×
    2×
    2×
    2×
    2×
    2×
    2×
    2×
    2×
    2×
    2×
    2×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×

    1×
    1×

    1×
    1×

     /*!
     * @author electricessence / https://github.com/electricessence/
     * Originally based upon .NET source but with many additions and improvements.
     * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
     */
    var __extends = (this && this.__extends) || function (d, b) {
        for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
    (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", "./TimeQuantity"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var TimeQuantity_1 = require("./TimeQuantity");
        var ClockTime = (function (_super) {
            __extends(ClockTime, _super);
            function ClockTime() {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i - 0] = arguments[_i];
                }
                _super.call(this, args.length > 1
                    ? ClockTime.millisecondsFromTime(args[0] || 0, args[1] || 0, args.length > 2 && args[2] || 0, args.length > 3 && args[3] || 0)
                    : (args.length > 0 && args[0] || 0));
                var _ = this;
                var ms = Math.abs(_.getTotalMilliseconds());
                var msi = Math.floor(ms);
                _.tick = (ms - msi) * 10000;
                _.days = (msi / 86400000) | 0;
                msi -= _.days * 86400000;
                _.hour = (msi / 3600000) | 0;
                msi -= _.hour * 3600000;
                _.minute = (msi / 60000) | 0;
                msi -= _.minute * 60000;
                _.second = (msi / 1000) | 0;
                msi -= _.second * 1000;
                _.millisecond = msi;
                Object.freeze(_);
            }
            ClockTime.from = function (hours, minutes, seconds, milliseconds) {
                if (seconds === void 0) { seconds = 0; }
                if (milliseconds === void 0) { milliseconds = 0; }
                return new ClockTime(hours, minutes, seconds, milliseconds);
            };
            ClockTime.millisecondsFromTime = function (hours, minutes, seconds, milliseconds) {
                Iif (seconds === void 0) { seconds = 0; }
                Iif (milliseconds === void 0) { milliseconds = 0; }
                var value = hours;
                value *= 60;
                value += minutes;
                value *= 60;
                value += seconds;
                value *= 1000;
                value += milliseconds;
                return value;
            };
            ClockTime.prototype.toString = function () {
                var _ = this, a = [];
                if (_.days)
                    a.push(pluralize(_.days, "day"));
                if (_.hour)
                    a.push(pluralize(_.hour, "hour"));
                if (_.minute)
                    a.push(pluralize(_.minute, "minute"));
                if (_.second)
                    a.push(pluralize(_.second, "second"));
                if (a.length > 1)
                    a.splice(a.length - 1, 0, "and");
                return a.join(", ").replace(", and, ", " and ");
            };
            return ClockTime;
        }(TimeQuantity_1.TimeQuantity));
        exports.ClockTime = ClockTime;
        function pluralize(value, label) {
            if (Math.abs(value) !== 1)
                label += "s";
            return label;
        }
        Object.defineProperty(exports, "__esModule", { value: true });
        exports.default = ClockTime;
    });
    //# sourceMappingURL=ClockTime.js.map