UNPKG

typescript-dotnet-core

Version:

A the core classes and utilities of a JavaScript-Friendly .NET Based TypeScript Library.

8 lines (7 loc) 1.59 kB
"use strict"; /*! * @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-Core/blob/master/LICENSE.md */Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),TimeQuantity_1=require("./TimeQuantity"),ClockTime=function(o){function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=o.call(this,1<e.length?l.millisecondsFromTime(e[0]||0,e[1]||0,2<e.length&&e[2]||0,3<e.length&&e[3]||0):0<e.length&&e[0]||0)||this,n=Math.abs(i.getTotalMilliseconds()),r=Math.floor(n);return i.tick=1e4*(n-r),i.days=r/864e5|0,r-=864e5*i.days,i.hour=r/36e5|0,r-=36e5*i.hour,i.minute=r/6e4|0,r-=6e4*i.minute,i.second=r/1e3|0,r-=1e3*i.second,i.millisecond=r,Object.freeze(i),i}return tslib_1.__extends(l,o),l.from=function(e,t,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),new l(e,t,i,n)},l.millisecondsFromTime=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var r=e;return r*=60,r+=t,r*=60,r+=i,r*=1e3,r+=n},l.prototype.toString=function(){var e=this,t=[];return e.days&&t.push(pluralize(e.days,"day")),e.hour&&t.push(pluralize(e.hour,"hour")),e.minute&&t.push(pluralize(e.minute,"minute")),e.second&&t.push(pluralize(e.second,"second")),1<t.length&&t.splice(t.length-1,0,"and"),t.join(", ").replace(", and, "," and ")},l}(TimeQuantity_1.default);function pluralize(e,t){return 1!==Math.abs(e)&&(t+="s"),t}exports.ClockTime=ClockTime,exports.default=ClockTime; //# sourceMappingURL=ClockTime.js.map