-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
44 additions
and
47 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,9 +1,21 @@ | ||
/** | ||
* Returns the ISO string representation of that date | ||
* that is most commonly used in Clockodo, which is: | ||
* - normalized to UTC | ||
* - without milliseconds | ||
*/ | ||
export const dateToClockodoIsoString = (date: Date) => { | ||
return date.toISOString().replace(/\.\d{3}Z$/, "Z"); | ||
import { IsoDate, IsoUtcDateTime } from "../models/dateTime.js"; | ||
|
||
export const isoDateFromDateTime = (dateTime: Date) => { | ||
return [ | ||
dateTime.getFullYear(), | ||
String(dateTime.getMonth() + 1).padStart(2, "0"), | ||
String(dateTime.getDate()).padStart(2, "0"), | ||
].join("-") as IsoDate; | ||
}; | ||
|
||
export const isoDateFromTimestamp = (timestamp: number) => { | ||
return isoDateFromDateTime(new Date(timestamp)); | ||
}; | ||
|
||
export const isoUtcDateTimeFromDateTime = (dateTime: Date) => { | ||
return dateTime.toJSON().replace(/\.\d{3}Z$/, "Z") as IsoUtcDateTime; | ||
}; | ||
|
||
export const isoUtcDateTimeFromTimestamp = (timestamp: number) => { | ||
return isoUtcDateTimeFromDateTime(new Date(timestamp)); | ||
}; |
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
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