Skip to content

Commit

Permalink
feat(todayutc): add todayUtc function
Browse files Browse the repository at this point in the history
  • Loading branch information
djcsdy committed Mar 29, 2020
1 parent dea8932 commit bf8b51e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -321,4 +322,9 @@ export function latest<T extends Readonly<Date>, U extends Readonly<Date>>(a: T,

export function latestFn<T extends Readonly<Date>, U extends Readonly<Date>>(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()};
}
4 changes: 4 additions & 0 deletions js-date.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type JsDate = Date;

// tslint:disable-next-line:variable-name
export const JsDate = Date;

0 comments on commit bf8b51e

Please sign in to comment.