Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add time spec #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add time spec #8

wants to merge 2 commits into from

Conversation

Xe
Copy link
Contributor

@Xe Xe commented Sep 8, 2018

extern int64 time_now();

@losfair
Copy link
Contributor

losfair commented Sep 9, 2018

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
Copy link
Contributor Author

Xe commented Sep 14, 2018

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
Copy link

aykevl commented Oct 19, 2018

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.

None yet

3 participants