# Weird time out range problem

**URL:** <https://www.ruby-forum.com/t/weird-time-out-range-problem/106074>\
**Category:** Rails\
**Created:** [June 6, 2007, 5:31am UTC](https://www.ruby-forum.com/t/weird-time-out-range-problem/106074 "2007-06-06T05:31:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [June 6, 2007, 5:31am UTC](https://www.ruby-forum.com/t/weird-time-out-range-problem/106074/1 "2007-06-06T05:31:49Z")

</div>

I’ve got a basic text field where somebody can enter their birthdate.  
I’m using a virtual attribute and all is working fine except if a date  
is entered between 38 and 68.

Meaning that 01/01/69 will work fine and is interpreted as 01/01/1969  
but 01/01/68 gives me a time out of range error:

/usr/local/lib/ruby/1.8/time.rb:184:in `local' /usr/local/lib/ruby/1.8/time.rb:184:in`make\_time’  
/usr/local/lib/ruby/1.8/time.rb:243:in `parse' app/models/user.rb:30:in`birthdate\_string=’  
app/controllers/users\_controller.rb:13:in `create’

Everything outside of 38 and 68 is ok. Anyone heard of such a thing?

Here’s my model:

def birthdate\_string  
birthdate.to\_s(:db)  
end

def birthdate\_string=(birthdate\_str)  
self.birthdate = Time.parse(birthdate\_str)  
if self.birthdate.year \< 1000  
self.birthdate += 1900.years  
elsif self.birthdate.year \> 2000  
self.birthdate -= 100.years  
end  
end
