diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-06-13 21:08:22 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-06-13 21:08:22 +0200 |
| commit | 3ff255b3f75d3c2d860ccd84aa06032f840ce0e6 (patch) | |
| tree | a693e36f007e5e4f3c20ecfffc91b2f2ad77b0ce /apps/web-shared/src/lib/helpers.ts | |
| parent | 39735309b2f2831ea8fe94104139fa0e9f6ace56 (diff) | |
| download | greatoffice-3ff255b3f75d3c2d860ccd84aa06032f840ce0e6.tar.xz greatoffice-3ff255b3f75d3c2d860ccd84aa06032f840ce0e6.zip | |
refactor: Introduce templated translation string for getting logged time today string
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) { |
