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:
That would change the time, making comparisons fail and so forth.
Since Timex doesn’t store time in the format shown in the first post, I’m guessing that a display function is being used that elides the trailing zero’s. If you could show that call that you use to print it then can show you how to adjust the formatter to keep the trailing zeros.
So if you can see my second command I had that function to add the time zone to the date, and that function is being called by the view with the date that is contained by the corresponding item.
So what I would need is that the convert returns the date with the trailing zeros.
I used IO.inspect to print the dates out of you meant that
Oh that is why! Timex prints out a shortened representation of the time it represents for debugging purposes. In general inspect is only for debugging purposes, not for an user interactions, instead you will want to use the formatting functions and guide available at: https://hexdocs.pm/timex/formatting.html
I wrap up my calls in functions to call, as my workplace likes a very…non-standard way of displaying dates for compatibility with older systems. ^.^;
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.
only the microsecond changes, so I have a normal DateTime at the start and as I saw you use from_unix so I changed the date with the DateTime.to_unix() and then gave it to this function but it only gives 1970-01-01 as a result no matter the date I give to it
How is that an incorrect value? It works down to microseconds in formatting, although your DateTime you gave it didn’t seem to have that (not a formatting problem) so it was zero’s.
That’s still changing the displayed time from what it actually is. Rather are you absolutely sure beyond any doubt that your DateTime that you are passing in actually has microsecond time? I’m not sure that changing the displayed time from the stored time is really a good “Solution” post as it could easily break things that other people may try to do the same with if all they read is that post and nothing else. ^.^;
oh nono, maybe I miss typed or something, but the issue was this: my saved times doesn’t have microseconds, but the app expects them for parsing reasons, not for any other use, so I just needed that DateTime to have microseconds in the format.