casting SysTime to ubyte[]
Laeeth Isharc via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jan 14 07:02:47 PST 2015
> I really wouldn't advise doing that. SysTime contains a long
> which
> represents the time in hnsecs since midnight, January 1st, 1
> A.D., and that
> could be written to a file quite easily. But it also contains a
> reference to
> a TimeZone object, so what you're doing would just be writing
> its address to
> disk, which wouldn't do you any good at all, since that's
> specific to each
> run of the program, even assuming that the object exists in
> both runs of the
> program (which it would for UTC or LocalTime but not for
> user-constructed
> time zones).
>
> So, writing the stdTime (horrible name, I know) property to
> disk would work
> just fine (that's the hnsecs as a long), but you're going to
> have to do
> something smarter than that if you want to retain the time
> zone. And you're
> not going to want to try and simply cast a SysTime to a ubyte[]
> and do
> anything practical with that regardless.
>
> - Jonathan M Davis
Thanks for this. I still with my C habits had the idea the time
would just be a flat struct. So in this case better to write it
as a string, which is what I have already done. I just wondered
why the other approach didn't work, and now I understand.
More information about the Digitalmars-d-learn
mailing list