elm-community / elm-time

A pure Elm date and time library.

Home Page:http://package.elm-lang.org/packages/elm-community/elm-time/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`fromISO8601` fails when date ends with `.000Z`

witoldsz opened this issue · comments

1970-01-01T00:00:00.000Z (this is how dateObj.toISOString() works)
Err "Errors encountered at position 19: expected \"Z\" or expected an integer"
1970-01-01T00:00:00Z
Ok (DateTime { date = Date { year = 1970, month = 1, day = 1 }, offset = 0 })

See: https://runelm.io/c/enq

Workaround:

DateTime.fromISO8601 <| Regex.replace Regex.All (regex "[.]000Z") (\_ -> "Z") str

Reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

@witoldsz Nice! Would you like to submit a pull request? If you've never submitted one, I can walk you thru it.

I don't get the idea of elm-combine yet. Will try to figure it out and then I could prepare the fix :) You know, years and years of OOP, I hope my brain is not damaged and I can still recover, heh

So this is how far I've get:

[ ~/projects ]$ git clone https://github.com/elm-community/elm-time.git
[ ~/projects ]$ cd elm-time
[ ~/projects/elm-time {master} ]$ elm-test
Starting downloads...

  ● elm-community/lazy-list 1.0.0
  ● elm-community/json-extra 2.1.0
  ● Bogdanp/elm-combine 3.1.1
  ● elm-community/elm-test 3.1.0
  ● elm-community/shrink 2.0.0
  ● elm-lang/lazy 2.0.0
  ● mgold/elm-random-pcg 4.0.2
  ● elm-lang/core 5.1.1
  
● rtfeldman/node-test-runner 3.0.0
Packages configured successfully!
Success! Compiled 61 modules.                                       
Successfully generated /tmp/elm_test_117121-7494-b5ir48.dx49ara4i.js
The test run failed because it encountered a runtime exception:

 RangeError: Maximum call stack size exceeded
    at /opt/node/lib/node_modules/elm-test/bin/elm-test:119:37
    at evalElmCode (/opt/node/lib/node_modules/elm-test/bin/elm-test:119:76)
    at /opt/node/lib/node_modules/elm-test/bin/elm-test:303:33
    at process._tickCallback (internal/process/next_tick.js:103:7)

[ ~/projects ]$ node --version
v7.4.0
[ ~/projects ]$ elm --version
0.18.0

I think I have seen this bug somewhere #13

No, all I did was the commands I've pasted. Haven't had time since then to further look into it.
:-(

OK, so I tried to figure out what's causing the troubles. I have discovered that the root cause of all this RangeError: Maximum call stack size exceeded is how Elm translates the List's […] into JavaScript. The longer the list is, the deeper the stack. With few hundreds elements it crashes.

I will file a bug and try to figure out a workaround.

List literal with many items leads to "Maximum call stack size exceeded"
elm-lang/core#840
"Maximum call stack size exceeded" with large List #1521
elm/compiler/issues/1521

Merged #23 to I'm closing this issue. @witoldsz, thanks for the PR; it was perfect

Version in elm-community has been bumped to 1.0.2