Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
0fb1e13ba0 | |||
ff4401934c |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.22.9",
|
||||
"version": "0.22.11",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user