Skip to content

add time spec#8

Open
Xe wants to merge 2 commits into
CommonWA:masterfrom
Xe:Xe/time
Open

add time spec#8
Xe wants to merge 2 commits into
CommonWA:masterfrom
Xe:Xe/time

Conversation

@Xe

@Xe Xe commented Sep 8, 2018

Copy link
Copy Markdown
Contributor
extern int64 time_now();

@losfair

losfair commented Sep 9, 2018

Copy link
Copy Markdown
Contributor

It would be better if we can have a more accurate way to represent the current time and make it the only way at the core API layer, like milliseconds/nanoseconds/struct timeval.

@Xe

Xe commented Sep 14, 2018

Copy link
Copy Markdown
Contributor Author

This makes sense. How would you propose this?

I bike shed the following C-like struct if only because it mirrors what the Go runtime uses for time values to make the code easier for me to write:

struct time_timeval {
  int64 unix_time_gmt_seconds;
  int64 nanoseconds_since_last_whole_second;
} 

@aykevl

aykevl commented Oct 19, 2018

Copy link
Copy Markdown

Agreed on the time accuracy issue. Providing only seconds is way too limiting for many applications.

Another (possibly simpler) option is to go with just a i64 of nanoseconds. This provides a range of ~600 years, ending in the year 2276. I guess that should be long enough. However, that's not compatible with clock_gettime while the proposed struct above is.

Yet another observation: what about different kinds of times? clock_gettime has many different kinds of times. In particular, the "time since boot" that isn't affected by clock changes (like with ntp) would be useful, and is used internally by the Go runtime for differences in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants