Re: representing a span of time

x = 64299600.0
Brad
Are these values seconds since epoch? If so:

irb(main):002:0> Time.at(1157489583.2798 - 64299600.0)
=> Sun Aug 22 09:53:03 MDT 2004

Regards,

Dan

This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.

Berger, Daniel wrote:

x = 64299600.0
Brad
Are these values seconds since epoch? If so:

irb(main):002:0> Time.at(1157489583.2798 - 64299600.0)
=> Sun Aug 22 09:53:03 MDT 2004

They are dates in time from Time.mktime(1972, 1, 15, 0, 0, 0) and
Time.now() represented as floats. Basically, I would like to show the
difference in a human significant way (years, months, days, etc.)

On Wed, 6 Sep 2006, Brad T. wrote:

difference in a human significant way (years, months, days, etc.)
They are dates in time from Time.mktime(1972, 1, 15, 0, 0, 0) and
Time.now() represented as floats. Basically, I would like to show the

harp:~ > cat a.rb
require ‘rubygems’
require ‘timeunits’

a = Time.mktime(1972, 1, 15, 0, 0, 0).utc
b = Time.now.utc

delta = b - a

puts delta.decades
puts delta.years
puts delta.months
puts delta.days
puts delta.minutes
puts delta.seconds

harp:~ > ruby a.rb
3.76567099435856
37.6567099435856
451.880519323027
12652.6545410448
18219822.5391045
1093189352.34627

-a

On Wed, 6 Sep 2006, Brad T. wrote:

37.6567099435856 #This should be 34 years… what is it 37? (2006 - 1972 = 34)
basically because it’s using 28 days months since it’s impossible to
tell when
one says

2.months

whether that should be 28 + 31 vs. 29 + 31 days, etc. so 1.month is
simply
equal to 4.weeks and 1.year is 12.months. however, i that is not good
behaviour so the latest release will give:

 harp:~ > cat a.rb
 require 'yaml'
 require 'rubygems'
 require 'timeunits'

 a = Time.mktime(1972, 1, 15, 0, 0, 0).utc
 b = Time.now.utc

 delta = b - a
 y 'delta.years' => delta.years

 seconds_per_day = 1.day
 y 'seconds_per_day' => seconds_per_day

 n_days = 0 and ((a += seconds_per_day and n_days += 1) while a < b)
 y 'n_days' => n_days

 days_per_year = 365
 n_years = Float(n_days)/Float(days_per_year)
 y 'n_years' => n_years


 harp:~ > ruby a.rb
 delta.years: 34.6651137623302
 seconds_per_day: 86400
 n_days: 12653
 n_years: 34.6657534246575

i may re-consider the method used to set the delta fields to another
method.

thanks for the bug report.

-a

a = Time.mktime(1972, 1, 15, 0, 0, 0).utc
b = Time.now.utc

delta = b - a

puts delta.decades
puts delta.years

harp:~ > ruby a.rb
3.76567099435856
37.6567099435856 #This should be 34 years… what is it 37? (2006 - 1972 = 34)