Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range error with varied local time string #22

Open
peterphilips opened this issue Jun 28, 2023 · 1 comment
Open

Range error with varied local time string #22

peterphilips opened this issue Jun 28, 2023 · 1 comment

Comments

@peterphilips
Copy link

Hi, I've noticed if changing the owner timezone to another country i.e. something like Australia, (in config.ts -> OWNER_TIMEZONE), I get an error:
error lib\availability\helpers.ts (68:20) @ toLocaleTimeString

  • error Error [RangeError]: Value longGeneric out of range for Date.prototype.toLocaleTimeString options property timeZoneName
    at Date.toLocaleTimeString ()

    I've noticed this problem goes away by removing the timezonename: "longGeneric" clause in request.ts interval to human string fx ->
    '''
    function intervalToHumanString({
    start,
    end,
    timeZone,
    }: DateTimeIntervalWithTimezone): string {
    return ${formatLocalDate(start, { month: "long", day: "numeric", hour: "numeric", minute: "numeric", weekday: "long", timeZone, })} – ${formatLocalTime(end, { hour: "numeric", minute: "numeric", timeZone, timeZoneName: "longGeneric", })}
    }
    '''
    when removing timezonename: "longGeneric" i no longer have this problem i.e.
    '''
    function intervalToHumanString({
    start,
    end,
    timeZone,
    }: DateTimeIntervalWithTimezone): string {
    return `${formatLocalDate(start, {
    month: "long",
    day: "numeric",
    hour: "numeric",
    minute: "numeric",
    weekday: "long",
    timeZone,
    })} – ${formatLocalTime(end, {
    hour: "numeric",
    minute: "numeric",
    timeZone,

    })}`
    }
    '''

@timfee
Copy link
Owner

timfee commented Jun 28, 2023

Thank you for that find.

Sometimes (at least for some US timezones), the longGeneric response produced a more human-readable string. Sorry that my US-centricity gave you a headache, but appreciate you reporting the find. Will incorporate the fix. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants