-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Post scheduling Adds simple input for scheduling a post x minutes in the future. Do you want to pull in a date picker library for this? See LemmyNet/lemmy#5025 * lint * add date picker * Adding i18n, and fixing some fields (#2694) * fix edits * cleanup --------- Co-authored-by: Dessalines <[email protected]>
- Loading branch information
1 parent
6b5da8c
commit 8b7a4e7
Showing
4 changed files
with
75 additions
and
6 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
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 |
---|---|---|
@@ -1,3 +1,27 @@ | ||
export default function getUnixTime(text?: string): number | undefined { | ||
/** | ||
* Converts timestamp string to unix timestamp in seconds, as used by Lemmy API | ||
*/ | ||
export function getUnixTimeLemmy(text?: string): number | undefined { | ||
return text ? new Date(text).getTime() / 1000 : undefined; | ||
} | ||
/** | ||
* Converts timestamp string to unix timestamp in millis, as used by Javascript | ||
*/ | ||
export function getUnixTime(text?: string): number | undefined { | ||
return text ? new Date(text).getTime() : undefined; | ||
} | ||
|
||
/** | ||
* This converts a unix time to a local date string, | ||
* popping to tho nearest minute, and removing the Z for | ||
* javascript fields. | ||
*/ | ||
export function unixTimeToLocalDateStr(unixTime?: number): string | undefined { | ||
return unixTime | ||
? convertUTCDateToLocalDate(new Date(unixTime)).toISOString().slice(0, -8) | ||
: undefined; | ||
} | ||
|
||
function convertUTCDateToLocalDate(date: Date): Date { | ||
return new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000); | ||
} |
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