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

**URL:** <https://www.ruby-forum.com/t/date-new-2007-09-01-not-legal/120208>\
**Category:** Ruby\
**Created:** [November 14, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/date-new-2007-09-01-not-legal/120208 "2007-11-14T19:52:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [November 14, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/date-new-2007-09-01-not-legal/120208/1 "2007-11-14T19:52:10Z")

</div>

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

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [November 14, 2007, 7:56pm UTC](https://www.ruby-forum.com/t/date-new-2007-09-01-not-legal/120208/2 "2007-11-14T19:56:07Z")

</div>

> -----Original Message-----  
> From: removed\_email\_address@domain.invalid  
> [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Greg W.  
> 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.

Try Date.parse(‘2007-09-01’).

- doanld

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [November 14, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/date-new-2007-09-01-not-legal/120208/3 "2007-11-14T20:01:46Z")

</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

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [November 14, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/date-new-2007-09-01-not-legal/120208/4 "2007-11-14T20:07:14Z")

</div>

On Nov 14, 2007, at 10:52 , Greg W. wrote:

> 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 Date::new(ajd=0, of=0, sg=ITALY)

```
  NOTE this is the documentation for the method new!(). If you are
  reading this as the documentation for new(), that is because rdoc
  doesn't fully support the aliasing of the initialize() method.
  new() is in fact an alias for #civil(): read the documentation for
  that method instead.

  Create a new Date object.

  ajd is the Astronomical Julian Day Number. of is the offset from
  UTC as a fraction of a day. Both default to 0.

  sg specifies the Day of Calendar Reform to use for this Date
  object.

  Using one of the factory methods such as Date::civil is generally
  easier and safer.
```
