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

Time.getZoneName incorrectly handles missing Intl support in ie11 #29

Open
stephenreddek opened this issue Dec 15, 2020 · 0 comments
Open

Comments

@stephenreddek
Copy link

Using Time.getZoneName in ie11 results in an invalid state for ZoneName. Instead of falling back to the timezone offset, it holds undefined in the Name variant.

Screen Shot 2020-12-15 at 14 23 39 PM

The kernel code seems to expect a failure when Intl isn't fully supported, but ie11 just gives undefined.

var name = __Time_Name(Intl.DateTimeFormat().resolvedOptions().timeZone); results in __Time_Name(undefined) rather than throwing an exception which could be caught and used to find an offset.

Screen Shot 2020-12-15 at 14 05 43 PM

SSCCE ellie gist
raw:

module Main exposing (main)

import Browser
import Html exposing (Html, div, span, text)
import Time exposing (ZoneName(..))
import Task


type alias Model =
    Maybe ZoneName


initialModel : () -> (Model, Cmd Msg)
initialModel () =
    (Nothing, Task.perform Zone Time.getZoneName)


type Msg
    = Zone ZoneName

update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
    case msg of
        Zone zone ->
            (Just zone, Cmd.none)



view : Model -> Html Msg
view model =
    div []
        [ span []
            [ case model of
                Just (Name zoneName) ->
                    text ("Timezone name: [" ++ zoneName ++ "]")
                
                Just (Offset offset) ->
                    text ("Timezone offset: [" ++ String.fromInt offset ++ "]")
                
                Nothing ->
                    text "no timezone result"
        
            ] 
        ]


main : Program () Model Msg
main =
    Browser.element
        { init = initialModel
        , view = view
        , update = update
        , subscriptions = always Sub.none
        }

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

1 participant