The only ones that really makes sense to auto convert through a port is ISO 
string or JS native. If you use a strange object, then yeah you would need 
manual conversion.

Re encoding: You can pass the value over as Json.Value and decode it, no?

On Monday, August 22, 2016 at 11:25:31 AM UTC-5, OvermindDL1 wrote:
>
> Too many formats for date though.  ;-)
>
> Such as is it in a format of a String?  With or without timezone?  Is it 
> in the format of a record like this that I use:
> ```elm
> type alias JsonDateTime =
>     { year : Int
>     , timezone :
>         { until : String
>         , offset_utc : Int
>         , offset_std : Int
>         , full_name : String
>         , from : String
>         , abbreviation : String
>         }
>     , second : Int
>     , month : Int
>     , minute : Int
>     , millisecond : Int
>     , hour : Int
>     , day : Int
>     , calendar : String
>     }
> ```
> The above record is parsed by the Javascript Date object without issue, 
> but nothing in Elm takes it so I have some nasty converting.  But there are 
> lots of ways and things.  Customized Encoding/Decoding for ports would be 
> awesome though.
>
>
> On Monday, August 22, 2016 at 9:55:39 AM UTC-6, Kasey Speakman wrote:
>>
>> Well, I'd wish for Dates to just automatically come over first. :)
>>
>> On Monday, August 22, 2016 at 10:50:39 AM UTC-5, OvermindDL1 wrote:
>>>
>>> I use the method of two records, one that comes in the port and one 
>>> after massaging it into the better format at the subscription step.  It is 
>>> ugly but I do not really see a way around it without being able to somehow 
>>> define our own Encoders/Decoders for ports (which I wish!).
>>>
>>>
>>> On Monday, August 22, 2016 at 9:22:06 AM UTC-6, Kasey Speakman wrote:
>>>>
>>>> If I have a record with a Date field, and I need to receive that 
>>>> through a port (which I understand is not possible). Do I have to de/code 
>>>> the whole record just because of this or is there a better way?
>>>>
>>>> Another way that occurs to me is to create two records, one with the 
>>>> date as a string for going through the port. Then once it gets inside Elm, 
>>>> use Date.fromString and map to the actual record type. Seems only slightly 
>>>> better than de/coding.
>>>>
>>>> Thoughts?
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to