-
Notifications
You must be signed in to change notification settings - Fork 10
Hybrid string date objects' known gotchas
Pedro Fayolle edited this page May 11, 2020
·
1 revision
E.g.:
Date === string_date_instance # => false
The 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 #=> false
instead of a String
TODO: Fix this.