Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

millisenconds/seconds since epoch

Moderators: larsivi kris

Posted: 08/21/07 19:07:01

How I get the seconds since epoch on linux? Clock.now() right now is printing 633233199367185000 don't make any sense to me even if I divide by Time.TicksPerSecond? > 63323319936

Author Message

Posted: 09/02/07 00:09:11

Which epoch? :p

The Tango clock starts at the year 0, and runs until the year 10,000 in increments of 100ns. Clock.now() returns a type of Time, which you will find in tango.core.Type ... there are a number of constants within Time that support manipulation of the value. Hope that helps?

Posted: 09/02/07 08:14:21

There's some more info here

Posted: 09/04/07 18:07:49

I want milliseconds since 1970 (i'm trying to emulate the Java function System.currentTimeMillis()).

Posted: 09/04/07 21:30:00

Check http://dsource.org/projects/tango/forums/topic/185#784

Maybe (Clock.now()-Time.TicksTo?1970)/Time.TicksPerSecond? ?

Posted: 09/05/07 10:41:19

Just to make things clearer for everyone wouldn't be easier to have something as Clock.timestamp? Counting the questions and complaints about the somehow non-orthodox way of Tango dealing with this very basic issue gives us a hint that a simpler, more traditional solution should be offered to new users.

Posted: 09/05/07 15:59:31

non-orthodox? Hehe ... well, it won't run out of stream in 2032 if that's what you mean :)

We're somewhat hesitant about adding a clockticks to both Clock & WallClock?, partly because the name doesn't really mean anything, and partly due to perceived 'bloat'. I wonder if a to1970Epoch/from1970Epoch pair of functions placed somewhere would make more sense?

Posted: 09/05/07 16:05:38

I, for one, would like that.

Posted: 09/05/07 17:23:35

Adding a Clock/WallClock.to1970Epoch/from1970Epoch would be greatly helpfull, I use such timestamps all the time.

Posted: 09/05/07 20:22:47

great, that would definitely help. maybe you get more creative with naming those methods :)

Posted: 09/05/07 21:05:33

Perhaps what it needs is a macro :)