@platform/util.value
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -0,7 +1,4 @@ | ||
import { IDate } from './types'; | ||
export declare function toTimestamp(date?: Date): number; | ||
export declare function fromTimestamp(timestamp: number): Date; | ||
export declare function utc(input?: Date | number): { | ||
readonly date: Date; | ||
readonly timestamp: number; | ||
readonly unix: number; | ||
}; | ||
export declare function utc(input?: Date | number): IDate; |
@@ -15,7 +15,7 @@ "use strict"; | ||
var date = input === undefined ? new Date() : typeof input === 'object' ? input : fromTimestamp(input); | ||
return { | ||
var res = { | ||
get date() { | ||
return date; | ||
}, | ||
get timestamp() { | ||
get time() { | ||
return toTimestamp(date); | ||
@@ -27,3 +27,4 @@ }, | ||
}; | ||
return res; | ||
} | ||
exports.utc = utc; |
@@ -29,4 +29,4 @@ "use strict"; | ||
var utc = _1.time.utc(); | ||
chai_1.expect(utc.date).to.eql(_1.time.fromTimestamp(utc.timestamp)); | ||
chai_1.expect(utc.timestamp).to.eql(_1.time.toTimestamp(utc.date)); | ||
chai_1.expect(utc.date).to.eql(_1.time.fromTimestamp(utc.time)); | ||
chai_1.expect(utc.time).to.eql(_1.time.toTimestamp(utc.date)); | ||
chai_1.expect(utc.unix).to.eql(_1.time.day(utc.date).unix()); | ||
@@ -38,3 +38,3 @@ }); | ||
chai_1.expect(utc.date).to.eql(_1.time.fromTimestamp(now)); | ||
chai_1.expect(utc.timestamp).to.eql(now); | ||
chai_1.expect(utc.time).to.eql(now); | ||
chai_1.expect(utc.unix).to.eql(_1.time.day(now).unix()); | ||
@@ -46,3 +46,3 @@ }); | ||
chai_1.expect(utc.date).to.eql(now); | ||
chai_1.expect(utc.timestamp).to.eql(_1.time.toTimestamp(now)); | ||
chai_1.expect(utc.time).to.eql(_1.time.toTimestamp(now)); | ||
chai_1.expect(utc.unix).to.eql(_1.time.day(now).unix()); | ||
@@ -56,5 +56,5 @@ }); | ||
chai_1.expect(utc.date).to.eql(d); | ||
chai_1.expect(utc.timestamp).to.eql(_1.time.toTimestamp(d)); | ||
chai_1.expect(utc.time).to.eql(_1.time.toTimestamp(d)); | ||
chai_1.expect(utc.unix).to.eql(_1.time.day(d).unix()); | ||
}); | ||
}); |
@@ -11,4 +11,4 @@ import { Dayjs, ConfigType } from 'dayjs'; | ||
day: DayFactory; | ||
now: IUtc; | ||
utc(input?: Date | number): IUtc; | ||
now: IDate; | ||
utc(input?: Date | number): IDate; | ||
timer(start?: Date, options?: { | ||
@@ -20,5 +20,5 @@ round?: number; | ||
}; | ||
export declare type IUtc = { | ||
export declare type IDate = { | ||
date: Date; | ||
timestamp: number; | ||
time: number; | ||
unix: number; | ||
@@ -25,0 +25,0 @@ }; |
{ | ||
"name": "@platform/util.value", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"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
147295
3879