-
Notifications
You must be signed in to change notification settings - Fork 8
Hybrid string date objects' known gotchas
Pedro Fayolle edited this page May 11, 2020
·
1 revision
E.g.:
Date === string_date_instance # => falseThe above can affect case conditions, as trying to match a StringDate with:
case obj
when Date
# ......will not work.
Instead one must specify the FmRest::StringDate class:
case obj
when Date, FmRest::StringDate
# ...TODO: Verify if this can affect hash indexing when a StringDate is used as a key.
StringDate#succ and StringDate#next return a String, despite Date#succ
and Date#next also existing.
Workaround: Use StringDate#next_day or string_date + 1
representation
Workaround: Use strdate.to_date.to_s
This is of course important when using a StringDate as a hash key.
TODO: Verify.
Workaround: Use strdate.to_date.as_json
str_date == date #=> true
date == str_date #=> falseinstead of a String
TODO: Fix this.