Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Clarification on to_date method of DateTime class #23

Open
runwaldarshu opened this issue Feb 17, 2015 · 5 comments
Open

Clarification on to_date method of DateTime class #23

runwaldarshu opened this issue Feb 17, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@runwaldarshu
Copy link

I would like to know what type of object to expect when we call to_date method on DateTime object.
I was hoping that will be ISO8601::Date object but seeing some different results.
For instance if I call new on Date object "ISO8601::Date.new('2014-05-02')" I can call weeks method on it and returns correct results but I do same with DateTime class and to_date method get an error

2.1.5 :001 > require 'iso8601'
 => true
2.1.5 :002 > ISO8601::Date.new('2014-W05').week
 => 5
2.1.5 :003 > ISO8601::DateTime.new('2014-05-02').to_date.week
NoMethodError: undefined method `week' for #<Date: 2014-05-02 ((2456780j,0s,0n),+0s,2299161j)>
    from (irb):3
    from /Users/DR029931/.rvm/rubies/ruby-2.1.5/bin/irb:11:in `<main>'

Just wanted some clarification for my understanding.

@arnau
Copy link
Owner

arnau commented Feb 17, 2015

Hi,

ISO8601::DateTime#to_date converts to the standard date Date object.

Right now there is no interface for converting from ISO8601::DateTime to ISO8601::Date.

@arnau
Copy link
Owner

arnau commented Feb 17, 2015

I guess we could add interfaces for converting to the other classes, something like #to_iso8601date, #to_iso8601time.

@runwaldarshu
Copy link
Author

This is something came up from my usecase It will be completely fine if you do not want to do this.

@arnau
Copy link
Owner

arnau commented Feb 17, 2015

Ok, let me give it a thought

@arnau arnau added this to the 0.9.0 milestone Apr 22, 2015
@arnau arnau self-assigned this Apr 22, 2015
@arnau
Copy link
Owner

arnau commented Apr 22, 2015

I'm planning to add a conversion interface like #to_iso8601_date, #to_iso8601_time for 0.9.0

@arnau arnau added feature and removed enhancement labels Apr 22, 2015
@arnau arnau modified the milestones: 0.9.0, 0.9.1, 1.0.0 Dec 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants