From bf8b51e2617c965164269c67bc9adbfe539163c9 Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Sun, 29 Mar 2020 19:51:04 +0100 Subject: [PATCH] feat(todayutc): add todayUtc function --- index.ts | 6 ++++++ js-date.ts | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 js-date.ts diff --git a/index.ts b/index.ts index e0e41c48..64592cac 100644 --- a/index.ts +++ b/index.ts @@ -3,6 +3,7 @@ import {Comparator, Comparison} from "@softwareventures/ordered"; import isInteger = require("is-integer"); import isIntegerInRange from "is-integer-in-range"; +import {JsDate} from "./js-date"; /** An date in the Gregorian calendar, with no associated time zone. */ export interface Date { @@ -321,4 +322,9 @@ export function latest, U extends Readonly>(a: T, export function latestFn, U extends Readonly>(b: U): (a: T) => T | U { return a => latest(a, b); +} + +export function todayUtc(): Date { + const today = new JsDate(); + return {day: today.getUTCDate(), month: today.getUTCMonth() + 1, year: today.getUTCFullYear()}; } \ No newline at end of file diff --git a/js-date.ts b/js-date.ts new file mode 100644 index 00000000..1648da47 --- /dev/null +++ b/js-date.ts @@ -0,0 +1,4 @@ +export type JsDate = Date; + +// tslint:disable-next-line:variable-name +export const JsDate = Date; \ No newline at end of file