Skip to content

Commit

Permalink
chore: add docstring to formatTimezoneAdjustedTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshaheer committed Dec 2, 2024
1 parent 44a3f1b commit 2b4b0ed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/src/hooks/useTimezoneFormatter/useTimezoneFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ function useTimezoneFormatter({
sortedEntries.slice(0, entriesToRemove).forEach(([key]) => cache.delete(key));
}, [cache]);

/**
* Formats a timestamp with the user's timezone and caches the result
* @param {TimestampInput} input - The timestamp to format (string, number, or Date)
* @param {string} [format='YYYY-MM-DD HH:mm:ss'] - The desired output format
* @returns {string} The formatted timestamp string in the user's timezone
* @example
* // Input: UTC timestamp
* // User timezone: 'UTC - 4'
* // Returns: "2024-03-14 15:30:00"
* formatTimezoneAdjustedTimestamp('2024-03-14T19:30:00Z')
*/
const formatTimezoneAdjustedTimestamp = useCallback(
(input: TimestampInput, format = 'YYYY-MM-DD HH:mm:ss'): string => {
const timestamp = dayjs(input).valueOf();
Expand Down

0 comments on commit 2b4b0ed

Please sign in to comment.