Compare commits

..

2 Commits

Author SHA1 Message Date
0fb1e13ba0 Fixed timezone adjust
All checks were successful
Build / Build NPM Project (push) Successful in 1m12s
Build / Tag Version (push) Successful in 11s
Build / Publish Documentation (push) Successful in 2m4s
2024-11-20 10:04:17 -05:00
ff4401934c Fixed formatDate month shortform
All checks were successful
Build / Build NPM Project (push) Successful in 1m21s
Build / Tag Version (push) Successful in 13s
Build / Publish Documentation (push) Successful in 1m57s
2024-11-16 11:02:32 -05:00
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.22.9",
"version": "0.22.11",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -22,8 +22,8 @@ export function adjustedInterval(cb: Function, ms: number) {
export function adjustTz(date: Date, offset: number) {
const currentOffset = date.getTimezoneOffset();
offset = currentOffset - offset * 60;
return new Date(date.getTime() + offset * 60000);
const adjustedOffset = offset * 60;
return new Date(date.getTime() + (currentOffset - adjustedOffset) * 60000);
}
/**
@ -100,7 +100,7 @@ export function formatDate(date: Date | number | string, format = 'YYYY-MM-DD H:
.replaceAll('YY', date.getFullYear().toString().slice(2))
// Month
.replaceAll('MMMM', month(date.getMonth()))
.replaceAll('MMM', month(date.getMonth()).slice(0, 2))
.replaceAll('MMM', month(date.getMonth()).slice(0, 3))
.replaceAll('MM', (date.getMonth() + 1).toString().padStart(2, '0'))
.replaceAll('M', (date.getMonth() + 1).toString())
// Day