Refactor getTimezoneAbbreviation function in date utility for improved readability and efficiency.
This commit is contained in:
@@ -46,11 +46,7 @@ export const getAdjustedTime = (): Moment => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getTimezoneAbbreviation = (date: Date): string => {
|
export const getTimezoneAbbreviation = (date: Date): string => {
|
||||||
const timezone = date
|
const timezone = date.toString().match(/\(.+\)/g)?.[0] ?? ''.replace('(', '') ?? ''.replace(')', '');
|
||||||
.toString()
|
|
||||||
.match(/\(.+\)/g)?.[0] ?? ''
|
|
||||||
.replace('(', '') ?? ''
|
|
||||||
.replace(')', '');
|
|
||||||
let abbreviation = '';
|
let abbreviation = '';
|
||||||
|
|
||||||
timezone.split(' ').forEach(word => {
|
timezone.split(' ').forEach(word => {
|
||||||
|
|||||||
Reference in New Issue
Block a user