-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactor font management across apps for consistency and remove Go…
…ogle Fonts dependency ✨ Introduce CSS custom properties for font stack to enhance maintainability ✅ Update eventParameters.spec.ts tests to use utility functions for time manipulation, improving test reliability and readability ✨ (time lib): add utils with timezone conversion functions for better date manipulation 💄 (ui components): update global font stack and remove external Inter font dependency for improved performance and customization 🔥 (ui components): remove preview-head.html to clean up and streamline Storybook configuration
- Loading branch information
1 parent
f662689
commit ea54813
Showing
14 changed files
with
93 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { addHours, subHours } from 'date-fns'; | ||
import { format, toZonedTime } from 'date-fns-tz'; | ||
|
||
/** | ||
* Converts a date to a specified time zone and formats it for display or further processing. | ||
* @param {Date} date - The date to convert. | ||
* @param {string} timeZone - The IANA time zone name. | ||
* @returns {string} - The formatted date string in the specified time zone. | ||
*/ | ||
export const convertDateToTimeZone = (date: Date, timeZone: string): string => { | ||
const zonedDate = toZonedTime(date, timeZone); | ||
return format(zonedDate, 'yyyy-MM-dd HH:mm:ssXXX', { timeZone }); | ||
}; | ||
|
||
/** | ||
* Adds hours to a date in a specific time zone. | ||
* @param {Date} date - The original date. | ||
* @param {number} hours - The number of hours to add. | ||
* @param {string} timeZone - The IANA time zone name. | ||
* @returns {Date} - The new date with added hours, considered in the specified time zone. | ||
*/ | ||
export const addHoursInTimeZone = ( | ||
date: Date, | ||
hours: number, | ||
timeZone: string, | ||
): Date => { | ||
const zonedDate = toZonedTime(date, timeZone); | ||
const newDate = addHours(zonedDate, hours); | ||
return toZonedTime(newDate, timeZone); // Convert back if needed, or adjust as per use case | ||
}; | ||
|
||
/** | ||
* Subtracts hours from a date in a specific time zone. | ||
* @param {Date} date - The original date. | ||
* @param {number} hours - The number of hours to subtract. | ||
* @param {string} timeZone - The IANA time zone name. | ||
* @returns {Date} - The new date with subtracted hours, considered in the specified time zone. | ||
*/ | ||
export const subHoursInTimeZone = ( | ||
date: Date, | ||
hours: number, | ||
timeZone: string, | ||
): Date => { | ||
const zonedDate = toZonedTime(date, timeZone); | ||
const newDate = subHours(zonedDate, hours); | ||
return toZonedTime(newDate, timeZone); // Convert back if needed, or adjust as per use case | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters