Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse::Date should support Times and Dates not just DateTimes #35

Open
ericcj opened this issue Aug 13, 2012 · 7 comments
Open

Parse::Date should support Times and Dates not just DateTimes #35

ericcj opened this issue Aug 13, 2012 · 7 comments

Comments

@ericcj
Copy link
Contributor

ericcj commented Aug 13, 2012

serialization should probably just give you DateTimes and coerce any of these instead of handing out Parse::Dates in the first place, but at the very least we shouldn't blow up on Times and Dates, or even ActiveSupport::TimeWithZone

@ericcj
Copy link
Contributor Author

ericcj commented Jan 21, 2013

we should do away with Parse::Date entirely and just serialize Times, Dates, and DateTimes properly on requests

@adelevie
Copy link
Owner

Agreed.

Sent from my iPhone

On Jan 21, 2013, at 8:16 AM, Eric Jensen notifications@github.com wrote:

we should do away with Parse::Date entirely and just serialize Times, Dates, and DateTimes properly on requests


Reply to this email directly or view it on GitHub.

@adelevie
Copy link
Owner

So proposed api should just be:

game_score["set_at"] = DateTime.now
# or
game_score["set_at"] = Time.now
# or
game_score["set_at"] = Date.now
# or
game_score["set_at"] = "01-22-2013" # mm-dd-yyy 

Also, I think we should still keep Parse::Date in master for a while until people have sufficient time to change. Maybe throw a warning?

Also also, should the serialization occur on request or right when the attribute gets set? Does it make any difference?

@ericcj
Copy link
Contributor Author

ericcj commented Jan 22, 2013

I don't think we should mess with parsing people's strings into dates for
them, but directly taking DateTime and Time would be nice. Don't forget
ActiveSupport::TimeWithZone which behaves like Time but does not
inherit any of them (active support does monkeypatch all three to respond to acts_like_time? though). The only real requirement is that the thing passed in
can be serialized with #iso8601(3), which all of these can as long as you
explicitly require 'time' and require 'date'.

Other nice properties would be that you can compare it directly ala
a['setAt'] < b['setAt'] and to external times like Time.now - a['setAt'].
A way of achieving both of these things would be to check if
respond_to?(:to_time) && !is_a(String) (since active_support adds
String#to_time) and if so then use that to normalize them all to Time
instances in that setter. the stdlib defines to_time but not to_datetime
so switching to Time makes sense. probably leave Parse::Date in but log
its deprecation with Kernel#warn to discourage its use.

While we're in that setter, it's a little weird that we allow you to set
values as any class that implements to_json (which is often any object
since active_support defines Object#to_json). At the very least we should
convert Parse::Objects you set directly to pointers instead of defaulting
to calling to_json on them which stores them as a hash in the parse table.

On Tue, Jan 22, 2013 at 11:52 AM, Alan deLevie notifications@github.comwrote:

So proposed api should just be:

game_score["set_at"] = DateTime.now# orgame_score["set_at"] = Time.now# orgame_score ["set_at"] = "01-22-2013" # mm-dd-yyy

Also, I think we should still keep Parse::Date in master for a while
until people have sufficient time to change. Maybe throw a warning?


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-12553724.

@ericcj
Copy link
Contributor Author

ericcj commented Jun 1, 2015

are you sure you want to close this? it's insanely annoying that you have to put DateTimes into parse-ruby-client and it barfs on Times

@xavdid
Copy link
Collaborator

xavdid commented Jun 1, 2015

Whoops! Thought this was a different one.

@rhymes
Copy link
Contributor

rhymes commented Jun 19, 2015

@ericcj let's discuss about this, I have some experiencing dealing with Date / Time / Timezone and so on with Rails and I agree. All parse-ruby-clients should do is:

  • take the object
  • convert it to UTC if it's not
  • call #iso8601(3) on it

How do you propose we go about this?

@rhymes rhymes self-assigned this Jun 19, 2015
@rhymes rhymes removed their assignment Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants