From 70d1cc4b8806c326a24e6aacaa2b2d222309dc31 Mon Sep 17 00:00:00 2001 From: somrat sorkar Date: Thu, 4 Jan 2024 14:49:15 +0600 Subject: [PATCH] update dateFormat using date-fns only --- package.json | 31 +++++++++++++++---------------- src/lib/utils/dateFormat.ts | 8 +++++--- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index d771a2e..db3eaba 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "astroplate", - "version": "3.1.2", + "version": "3.2.0", "description": "Astro and Tailwindcss boilerplate", "author": "zeon.studio", "license": "MIT", @@ -14,21 +14,20 @@ "remove-darkmode": "node scripts/removeDarkmode.js && yarn format" }, "dependencies": { - "@astrojs/mdx": "^2.0.2", - "@astrojs/react": "^3.0.8", + "@astrojs/mdx": "^2.0.3", + "@astrojs/react": "^3.0.9", "@astrojs/rss": "^4.0.1", - "@astrojs/sitemap": "^3.0.3", - "@astrojs/tailwind": "^5.0.4", - "astro": "^4.0.7", + "@astrojs/sitemap": "^3.0.4", + "@astrojs/tailwind": "^5.1.0", + "astro": "^4.0.9", "astro-auto-import": "^0.4.2", - "date-fns": "^2.30.0", - "date-fns-tz": "^2.0.0", + "date-fns": "^3.0.6", "disqus-react": "^1.1.5", "github-slugger": "^2.0.0", "gray-matter": "^4.0.3", - "marked": "^11.1.0", - "prettier-plugin-astro": "^0.12.2", - "prettier-plugin-tailwindcss": "^0.5.9", + "marked": "^11.1.1", + "prettier-plugin-astro": "^0.12.3", + "prettier-plugin-tailwindcss": "^0.5.10", "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -43,16 +42,16 @@ "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "@types/marked": "^5.0.2", - "@types/node": "20.10.5", - "@types/react": "18.2.45", + "@types/node": "20.10.6", + "@types/react": "18.2.46", "@types/react-dom": "18.2.18", "autoprefixer": "^10.4.16", "eslint": "^8.56.0", "postcss": "^8.4.32", "prettier": "^3.1.1", - "prettier-plugin-astro": "^0.12.2", - "prettier-plugin-tailwindcss": "^0.5.9", - "sass": "^1.69.5", + "prettier-plugin-astro": "^0.12.3", + "prettier-plugin-tailwindcss": "^0.5.10", + "sass": "^1.69.7", "tailwindcss": "^3.4.0", "tailwind-bootstrap-grid": "^5.1.0", "typescript": "5.3.3" diff --git a/src/lib/utils/dateFormat.ts b/src/lib/utils/dateFormat.ts index 1e533b7..9b960d5 100755 --- a/src/lib/utils/dateFormat.ts +++ b/src/lib/utils/dateFormat.ts @@ -1,10 +1,12 @@ -import { formatInTimeZone } from "date-fns-tz"; +import { format } from "date-fns"; const dateFormat = ( date: Date | string, - format: string = "dd MMM, yyyy", + pattern: string = "dd MMM, yyyy", ): string => { - return formatInTimeZone(date, "America/New_York", format); + const dateObj = new Date(date); + const output = format(dateObj, pattern); + return output; }; export default dateFormat;