Issue #8096 has been updated by phluid61 (Matthew Kerwin).


headius (Charles Nutter) wrote:
> phluid61 (Matthew Kerwin) wrote:
> >  There is this: https://github.com/phluid61/timestamp-gem
> >  
> >  The java stuff is experimentation on my part, published version of the gem
> >  has none of that.
> 
> You're pretty close. System.nanoTime is probably the closes thing to your "timestamp", but as kosaki points out it's not guaranteed to be monotonic (even your impl is not monotonic).

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.

> Your implementation for MRI is probably just fine. I can help make the JRuby version "correct" using nanoTime and proper method binding. But a few questions remain:
> 
> * 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.
----------------------------------------
Feature #8096: introduce Time.current_timestamp
https://bugs.ruby-lang.org/issues/8096#change-38611

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/