From 049d252a1acd7ca5c686d4e96acb9fd38bea5a71 Mon Sep 17 00:00:00 2001 From: Orlando Date: Fri, 10 May 2024 19:06:48 +0100 Subject: [PATCH] startOfDay --- CHANGELOG.md | 6 ++++++ package.json | 4 ++-- src/dates/index.ts | 1 + src/dates/startOfDay.ts | 3 +++ src/dates/startOfToday.ts | 6 ++++-- 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/dates/startOfDay.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index ca7767e..f439d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # deverything +## 0.51.0 + +### Minor Changes + +- startOfDay + ## 0.50.0 ### Minor Changes diff --git a/package.json b/package.json index 6894d99..3e1fba2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deverything", - "version": "0.50.0", + "version": "0.51.0", "description": "Everything you need for Dev", "main": "./dist/index.js", "module": "./dist/index.mjs", @@ -17,7 +17,7 @@ "lint": "TIMING=1 eslint src --fix", "prepublish": "pnpm test && pnpm build", "test": "jest", - "bump": "pnpm changeset && pnpm changeset version" + "release": "pnpm changeset && pnpm changeset version" }, "repository": { "type": "git", diff --git a/src/dates/index.ts b/src/dates/index.ts index 401ff3c..0655ab1 100644 --- a/src/dates/index.ts +++ b/src/dates/index.ts @@ -2,5 +2,6 @@ export * from "./isOver18"; export * from "./startOfNextMonth"; export * from "./startOfNextWeek"; export * from "./startOfThisWeek"; +export * from "./startOfDay"; export * from "./startOfToday"; export * from "./startOfTomorrow"; diff --git a/src/dates/startOfDay.ts b/src/dates/startOfDay.ts new file mode 100644 index 0000000..663db48 --- /dev/null +++ b/src/dates/startOfDay.ts @@ -0,0 +1,3 @@ +export const startOfDay = (day: Date): Date => { + return new Date(day.getFullYear(), day.getMonth(), day.getDate()); +}; diff --git a/src/dates/startOfToday.ts b/src/dates/startOfToday.ts index bc78965..5a43a03 100644 --- a/src/dates/startOfToday.ts +++ b/src/dates/startOfToday.ts @@ -1,4 +1,6 @@ -export const startOfToday = () => { +import { startOfDay } from "./startOfDay"; + +export const startOfToday = (): Date => { const now = new Date(); - return new Date(now.getFullYear(), now.getMonth(), now.getDate()); + return startOfDay(now); };