Issue #8096 has been updated by headius (Charles Nutter).


phluid61 (Matthew Kerwin) wrote:
> Actually since making the jruby branch, and based on some conversations here, I have changed the API of the gem (and the C implementation in master) to define a monotonic Time.timestamp method and a Time.now.to_i-equivalent wall-clock method, which I called Time.unix_timestamp because I couldn't think of a better name.
> 
> My intention was to update the jruby branch to use System.nanoTime for Time.timestamp, which I've finally gotten around to doing, but I see there are still potentially some polytonic (is that even a word?) issues to resolve.  Fortunately I've not yet set up my VM to build jruby/java-native gems, or verified my hopefully MRI-and-jruby compatible gemspec, so my java code won't be released into the wild for some time yet.

I could submit a PR for master that provides the same methods in a JRuby-compatible way, if you'd like.

> > * Do we want a single Time.timestamp method?
> > * If so, which timestamp is it?
> > * If not, how many representations of timestamp do we want? It seems to me that our timestamp and Time.now.to_i should probably be derived the same way.
> 
> This discussion has already revealed, to me at least, that some people want a fast seconds-since-1969 method, and some people want a secure, high-precision monotonicically increasing value.  I think the latter has the most merit, since there is currently no equivalent in Ruby; however both are legitimate requests.

Yes, those seem like the key points. The monotonicity guarantees of the latter are hard to meet, though...on any impl. it might have to be specified as "high-precision CPU-level timestamp, which will be monotonic on most systems (but this is not guaranteed)".

So we have:

* Time.timestamp: A ns-precision timestamp based on the fastest, most accurate timer possible on the current platform. Although not guaranteed, this value will be monotonic on most systems.
* Time.something_timestamp: A timestamp representing the number of seconds since the epoch.

I suggest epoch_timestamp for the latter.

Would this meet everyone's needs?
----------------------------------------
Feature #8096: introduce Time.current_timestamp
https://bugs.ruby-lang.org/issues/8096#change-38619

Author: vipulnsward (Vipul Amler)
Status: Feedback
Priority: Low
Assignee: 
Category: 
Target version: 


=begin
A lot of scenarios and applications require the use of (({Time.now.to_i})) which is used as current_timestamp in systems.

The introduction of (({Time.current_timestamp})) {or something with similar with different name} would provide implicit integer timestamp instead of going from 
(({Time.now})) -> time_object -> to_i -> integer timestamp value

So instead of

 Time.now.to_i # Outputs => 1363274618

one could use

 Time.current_timestamp # Outputs => 1363274618

=end



-- 
http://bugs.ruby-lang.org/