# Date.new('2007-09-01') not legal?

**URL:** <https://rubytalk.org/t/date-new-2007-09-01-not-legal/42196>\
**Category:** ruby-talk\
**Created:** [14 November 2007 18:52 UTC](https://rubytalk.org/t/date-new-2007-09-01-not-legal/42196 "2007-11-14T18:52:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Willits](https://avatars.discourse-cdn.com/v4/letter/g/cab0a1/32.png) [@Greg\_Willits](https://rubytalk.org/u/Greg_Willits)\
**Post date:** [14 November 2007 18:52 UTC](https://rubytalk.org/t/date-new-2007-09-01-not-legal/42196/1 "2007-11-14T18:52:08Z")

</div>

Is that form of creating a new date object really not legal? If so, that  
seems mighty odd.

-- gw

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Ball\_Donald\_A\_Jr\_Lib](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@Ball\_Donald\_A\_Jr\_Lib](https://rubytalk.org/u/Ball_Donald_A_Jr_Lib)\
**Post date:** [14 November 2007 18:55 UTC](https://rubytalk.org/t/date-new-2007-09-01-not-legal/42196/2 "2007-11-14T18:55:14Z")

</div>

Try Date.parse('2007-09-01').

- doanld

> **···**
>
> > -----Original Message-----  
> > From: list-bounce@example.com  
> > [mailto:list-bounce@example.com] On Behalf Of Greg Willits  
> > Sent: Wednesday, November 14, 2007 12:52 PM  
> > To: ruby-talk ML  
> > Subject: Date.new('2007-09-01') not legal?
> > 
> > Is that form of creating a new date object really not legal?  
> > If so, that seems mighty odd.

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [14 November 2007 19:04 UTC](https://rubytalk.org/t/date-new-2007-09-01-not-legal/42196/3 "2007-11-14T19:04:56Z")

</div>

> Is that form of creating a new date object really not legal? If so, that  
> seems mighty odd.

You want Date.parse.

$ ri Date.new  
-------------------------------------------------------------- Date::new

> **···**
>
> On Nov 14, 2007, at 10:52 , Greg Willits wrote:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date::new(ajd=0, of=0, sg=ITALY)  
> ------------------------------------------------------------------------  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NOTE this is the documentation for the method new!(). If you are  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reading this as the documentation for new(), that is because rdoc  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doesn't fully support the aliasing of the initialize() method.  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new() is in fact an alias for #civil(): read the documentation for  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that method instead.
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a new Date object.
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ajd is the Astronomical Julian Day Number. of is the offset from  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UTC as a fraction of a day. Both default to 0.
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sg specifies the Day of Calendar Reform to use for this Date  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;object.
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Using one of the factory methods such as Date::civil is generally  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easier and safer.
> 
> --  
> Poor workers blame their tools. Good workers build better tools. The  
> best workers get their tools to do the work for them. -- Syndicate Wars

---

<div class="post-metadata">

**Author:** ![Greg\_Willits](https://avatars.discourse-cdn.com/v4/letter/g/cab0a1/32.png) [@Greg\_Willits](https://rubytalk.org/u/Greg_Willits)\
**Post date:** [14 November 2007 19:01 UTC](https://rubytalk.org/t/date-new-2007-09-01-not-legal/42196/4 "2007-11-14T19:01:44Z")

</div>

> > Is that form of creating a new date object really not legal?  
> > If so, that seems mighty odd.
> 
> Try Date.parse('2007-09-01').

Whew 🙂

Weird, but I don't see this documented anywhere in "Programming Ruby"

Thanks!

-- gw

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
