@platform/util.value
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -15,4 +15,4 @@ "use strict"; | ||
get now() { | ||
return utc_1.utc(new Date()); | ||
return utc_1.utc(); | ||
}, | ||
}; |
@@ -5,4 +5,5 @@ import * as t from './types'; | ||
}): t.ITimer; | ||
export declare function elapsed(from: Date, options?: { | ||
export declare function elapsed(from: t.DateInput, options?: { | ||
to?: t.DateInput; | ||
round?: number; | ||
}): t.IDuration; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var day = require("dayjs"); | ||
var value_1 = require("../value"); | ||
@@ -28,4 +29,5 @@ var round = value_1.value.round; | ||
if (options === void 0) { options = {}; } | ||
var now = new Date(); | ||
var msec = now.getTime() - from.getTime(); | ||
var start = to.date(from); | ||
var end = options.to ? to.date(options.to) : new Date(); | ||
var msec = end.getTime() - start.getTime(); | ||
var defaultPrecision = options.round === undefined ? 1 : options.round; | ||
@@ -97,2 +99,3 @@ var duration = { | ||
day: function (msec, precision) { return round(msec / 1000 / 60 / 60 / 24, precision); }, | ||
date: function (input) { return day(input).toDate(); }, | ||
}; |
import { Dayjs, ConfigType } from 'dayjs'; | ||
export declare type TimeDelay = (msecs: number, callback?: () => void) => Promise<{}>; | ||
export declare type TimeWait = (msecs: number) => Promise<{}>; | ||
export declare type TimeElapsed = (from: Date) => IDuration; | ||
export declare type TimeElapsed = (from: DateInput, options?: { | ||
to?: DateInput; | ||
round?: number; | ||
}) => IDuration; | ||
export declare type DayFactory = (config?: ConfigType) => Dayjs; | ||
export declare type DateInput = number | string | Date | Dayjs; | ||
export declare type ITime = { | ||
@@ -7,0 +11,0 @@ delay: TimeDelay; |
@@ -1,2 +0,2 @@ | ||
import { IDate } from './types'; | ||
export declare function utc(input?: Date | number): IDate; | ||
import * as t from './types'; | ||
export declare function utc(input?: t.DateInput): t.IDate; |
@@ -5,12 +5,12 @@ "use strict"; | ||
function utc(input) { | ||
var date = input === undefined ? new Date() : typeof input === 'object' ? input : new Date(input); | ||
var date = day(input); | ||
var res = { | ||
get date() { | ||
return date; | ||
return date.toDate(); | ||
}, | ||
get timestamp() { | ||
return date.getTime(); | ||
return date.toDate().getTime(); | ||
}, | ||
get unix() { | ||
return day(date).unix(); | ||
return date.unix(); | ||
}, | ||
@@ -17,0 +17,0 @@ }; |
@@ -5,3 +5,3 @@ "use strict"; | ||
var _1 = require("."); | ||
describe.only('Version', function () { | ||
describe('Version', function () { | ||
it('has version value', function () { | ||
@@ -8,0 +8,0 @@ var res = _1.version('0.1.2'); |
{ | ||
"name": "@platform/util.value", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Helpers for working with, transforming, and formatting values.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
147675
3914