Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > dates earlier than 1970?

Reply
Thread Tools

dates earlier than 1970?

 
 
Kevin Howe
Guest
Posts: n/a
 
      11-03-2004
I have a web app that collects new employee info, one of the fields being
"Birth date". However since many of the employees were born earlier than
1970 I am unable to turn these into Ruby Time/Date objects. Is there a ruby
library that can handle dates earlier than 1970?


 
Reply With Quote
 
 
 
 
Jamis Buck
Guest
Posts: n/a
 
      11-03-2004
Kevin Howe wrote:
> I have a web app that collects new employee info, one of the fields being
> "Birth date". However since many of the employees were born earlier than
> 1970 I am unable to turn these into Ruby Time/Date objects. Is there a ruby
> library that can handle dates earlier than 1970?


String? I honestly don't mean that facetiously, either. If you enforce
the right format on the strings, you can do date-wise comparisons on
them, and extract date-part info via regexps:

"1964-07-25" < "1974-07-25"
year = "1964-07-25".match(/^(\d\d\d\d)-/ )[1].to_i

Certainly, the above could benefit from a minimal wrapper around it to
make things like date-part extraction less cumbersome. But for most of
the things I use dates for, strings suffice.

--
Jamis Buck
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.jamisbuck.org/jamis


 
Reply With Quote
 
 
 
 
Yukihiro Matsumoto
Guest
Posts: n/a
 
      11-03-2004
Hi,

In message "Re: dates earlier than 1970?"
on Thu, 4 Nov 2004 04:28:46 +0900, "Kevin Howe" <(E-Mail Removed)> writes:

|I have a web app that collects new employee info, one of the fields being
|"Birth date". However since many of the employees were born earlier than
|1970 I am unable to turn these into Ruby Time/Date objects. Is there a ruby
|library that can handle dates earlier than 1970?

(1) If your platform handles negative time_t, Time can be as old as
1902, which might be long enough to represent _most_ of employees'
birth date. Try Time.at(1965, 4, 14) for example.

(2) Date class can represent arbitrary date on the calendar, even back
to 4713 B.C, which covers, as I believe, _all_ employees.
Just require "date".

matz.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to use dates earlier than 1900 (Time library says out of range for dates < 1900) me@benjaminarai.com Ruby 1 07-17-2007 02:25 PM
Dates dates dates dates... SQL and ASP.NET David Lozzi ASP .Net 1 09-30-2005 02:18 PM
Dates! Dates! Dates! PW ASP General 4 08-09-2004 04:42 PM
Which IDE to choose (more specific than earlier, very similar post)? Gelmir TinehtelŽ Java 10 06-09-2004 07:39 PM
Must function defs appear earlier than calls? SeeBelow@SeeBelow.Nut Python 8 05-05-2004 01:55 AM



Advertisments