diff options
Diffstat (limited to 'apps/web-shared/src/lib/helpers.ts')
| -rw-r--r-- | apps/web-shared/src/lib/helpers.ts | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/apps/web-shared/src/lib/helpers.ts b/apps/web-shared/src/lib/helpers.ts index 1cf94f4..ad6f280 100644 --- a/apps/web-shared/src/lib/helpers.ts +++ b/apps/web-shared/src/lib/helpers.ts @@ -1,7 +1,7 @@ -import {base_domain, CookieNames} from "$shared/lib/configuration"; -import {TimeEntryDto} from "$shared/lib/models/TimeEntryDto"; -import {UnwrappedEntryDateTime} from "$shared/lib/models/UnwrappedEntryDateTime"; -import {Temporal} from "@js-temporal/polyfill"; +import { base_domain, CookieNames } from "$shared/lib/configuration"; +import { TimeEntryDto } from "$shared/lib/models/TimeEntryDto"; +import { UnwrappedEntryDateTime } from "$shared/lib/models/UnwrappedEntryDateTime"; +import { Temporal } from "@js-temporal/polyfill"; export const EMAIL_REGEX = new RegExp(/^([a-z0-9]+(?:([._\-])[a-z0-9]+)*@(?:[a-z0-9]+(?:(-)[a-z0-9]+)?\.)+[a-z0-9](?:[a-z0-9]*[a-z0-9])?)$/i); export const URL_REGEX = new RegExp(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-.][a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/gm); @@ -143,13 +143,20 @@ export function set_emoji_favicon(emoji: string) { // https://stackoverflow.com/a/48400665/11961742 -export function seconds_to_hour_minute_string(seconds: number) { +export function seconds_to_hour_minute_string(seconds: number, hourChar = "h", minuteChar = "m") { const hours = Math.floor(seconds / (60 * 60)); seconds -= hours * (60 * 60); const minutes = Math.floor(seconds / 60); return hours + "h" + minutes + "m"; } +export function seconds_to_hour_minute(seconds: number) { + const hours = Math.floor(seconds / (60 * 60)); + seconds -= hours * (60 * 60); + const minutes = Math.floor(seconds / 60); + return {hours, minutes}; +} + export function get_query_string(params: any = {}): string { const map = Object.keys(params).reduce((arr: Array<string>, key: string) => { if (params[key] !== undefined) { |
