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

Have toString display Date values in ISO format #481

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@fredcy
Contributor

fredcy commented Jan 14, 2016

The core toString function returns the String value "{}" for all Date values. That makes it hard to display Date values for debugging. This patch extends toString to display Date values in ISO format like "<date 2016-01-14T15:06:41.393Z>".

Here is a test program that I've been using. On regular intervals it displays the value of Time.every (to show liveness) and the corresponding Date value:

import Date
import Effects
import Html exposing (li, text, ul)
import StartApp
import Time

app =
  StartApp.start
    { init = ( 0, Effects.none )
    , inputs = [ Time.every <| Time.second * 5 ]
    , update = \t -> always ( t, Effects.none )
    , view = always showTime
    }

showTime t =
  ul
    []
    [ li [] [ t |> toString |> text ]
    , li [] [ t |> Date.fromTime |> toString |> text ]
    ]
@mietek

This comment has been minimized.

Show comment
Hide comment

mietek commented Jan 18, 2016

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Jan 19, 2016

Contributor

So, can this pull request be closed? I notice that while it addresses the same issue as #442, it does propose a slightly different code change. Is the one here better than the other one? Why?

Contributor

jvoigtlaender commented Jan 19, 2016

So, can this pull request be closed? I notice that while it addresses the same issue as #442, it does propose a slightly different code change. Is the one here better than the other one? Why?

@fredcy

This comment has been minimized.

Show comment
Hide comment
@fredcy

fredcy Jan 19, 2016

Contributor

I didn't notice https://github.com/elm-lang/core/pull/442 before opening this request. I'm OK with closing this request as a duplicate.

Contributor

fredcy commented Jan 19, 2016

I didn't notice https://github.com/elm-lang/core/pull/442 before opening this request. I'm OK with closing this request as a duplicate.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Jan 19, 2016

Contributor

Okay, I'm closing it, but copying your example program over to the other discussion, because it could be useful for testing over there as well.

Contributor

jvoigtlaender commented Jan 19, 2016

Okay, I'm closing it, but copying your example program over to the other discussion, because it could be useful for testing over there as well.

@lukewestby lukewestby referenced this pull request Jan 20, 2017

Closed

Date #816

2 of 7 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment