digitalmars.D.learn - How to get current time as long or ulong?
- Charles Hixson via Digitalmars-d-learn (10/10) Jul 05 2016 I've been reading std.datetime documentation backwards and forwards, but...
- John (2/14) Jul 05 2016 Clock.currTime.stdTime
- Jonathan M Davis via Digitalmars-d-learn (10/27) Jul 05 2016 That would give you the badly named "std" time and not "unix" time. "std...
- ag0aep6g (3/4) Jul 05 2016 That would be the "toUnixTime" method then, I suppose.
- yawniek (10/12) Jul 06 2016 i often use
I've been reading std.datetime documentation backwards and forwards, but if the information is there, I've been missing it. How do I get the current time as a long? Clock.currTime() returns a SysTime, and while currently I can convert that to a long, this is because I looked into the code. What's the supported way? All the documentation seems to be based around auto, which is great if you don't need to store it in memory with a defined number of bits allocated...but lousy if you do. (E.g., I don't want to store a time zone, just the UTC time. What I'm looking for is the opposite of the "FromUnixTime" function.
Jul 05 2016
On Tuesday, 5 July 2016 at 18:16:31 UTC, Charles Hixson wrote:I've been reading std.datetime documentation backwards and forwards, but if the information is there, I've been missing it. How do I get the current time as a long? Clock.currTime() returns a SysTime, and while currently I can convert that to a long, this is because I looked into the code. What's the supported way? All the documentation seems to be based around auto, which is great if you don't need to store it in memory with a defined number of bits allocated...but lousy if you do. (E.g., I don't want to store a time zone, just the UTC time. What I'm looking for is the opposite of the "FromUnixTime" function.Clock.currTime.stdTime
Jul 05 2016
On Tuesday, July 05, 2016 18:25:17 John via Digitalmars-d-learn wrote:On Tuesday, 5 July 2016 at 18:16:31 UTC, Charles Hixson wrote:That would give you the badly named "std" time and not "unix" time. "std" time is what SysTime uses internally and is the number of hecto-nanoseconds since midnight, January 1st, 1 A.D., whereas unix time is the number of seconds since midnight, January 1st, 1970. What SysTime uses is essentially "ticks", whereas unix time is what you normally get with C - though technically, if you're not on a POSIX system, there is no guarantee that time_t is equivalent to unix time - it just usually is. - Jonathan M DavisI've been reading std.datetime documentation backwards and forwards, but if the information is there, I've been missing it. How do I get the current time as a long? Clock.currTime() returns a SysTime, and while currently I can convert that to a long, this is because I looked into the code. What's the supported way? All the documentation seems to be based around auto, which is great if you don't need to store it in memory with a defined number of bits allocated...but lousy if you do. (E.g., I don't want to store a time zone, just the UTC time. What I'm looking for is the opposite of the "FromUnixTime" function.Clock.currTime.stdTime
Jul 05 2016
On 07/05/2016 08:16 PM, Charles Hixson via Digitalmars-d-learn wrote:What I'm looking for is the opposite of the "FromUnixTime" function.That would be the "toUnixTime" method then, I suppose. https://dlang.org/phobos/std_datetime.html#.SysTime.toUnixTime
Jul 05 2016
On Tuesday, 5 July 2016 at 18:16:31 UTC, Charles Hixson wrote:What I'm looking for is the opposite of the "FromUnixTime" function.i often use long toNsUnixTime(SysTime t) { return (t.stdTime - 621_355_968_000_000_000L)*100; } as a helper. any chance that something like this can be put into phobos? its needed to work with external libraries or network services that expect this format.
Jul 06 2016