benonymus
Timex.Timezone.convert/2 question
Hey I am using this function, and the result does only show until the seconds, doesn’t show milliseconds, not even the .000000. Why is that?
Before it did show it.
It used to return this:
2018-09-15T15:00:00.000000+02:00
and now it returns this:
2018-03-10T05:00:00-04:00
I am using timex 3.4
Marked As Solved
benonymus
ok so at the end I used Timex.set/2 and setting the microsecond field
Also Liked
NobbZ
Then please use proper formatting instead of relying on debug output that may change without a warning at any point in time.
NobbZ
If you want to format a time for presentation use Timex.format, the inspection output is for debugging only and might change its presentation without any warnings.
OvermindDL1
Hmm, as per the documentation I linked I don’t see why this wouldn’t work for you based on the information given?
iex(1)> Timex.format(DateTime.from_unix!(1549385336000000, :microsecond), "%FT%T.%f%z", :strftime)
{:ok, "2019-02-05T16:48:56.000000+0000"}
iex(2)> Timex.format(DateTime.from_unix!(1549385336000001, :microsecond), "%FT%T.%f%z", :strftime)
{:ok, "2019-02-05T16:48:56.000001+0000"}
OvermindDL1
Oh! Then my snippet should work perfectly for it as it always prints microseconds, even out to full 0’s if the datetime doesn’t contain them. You really don’t want to change a time to print out for something else, you’d be surprised by the bugs that can happen. ^.^
NobbZ
Can you give a more complete example about how you create the dates and how you convert them?







