Skip to content

Commit 9b66277

Browse files
neilshwekyp
andauthored
MONGOID-5425 Verify string mongoization into Date, Time, DateTime with time zones (#5387)
* MONGOID-5425 Verify string mongoization into Date, Time, DateTime with time zones * MONGOID-5425 fix CI tests * add docs Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent f470820 commit 9b66277

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

source/reference/fields.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ assignment to a ``Time`` field:
269269
In the above example, the value was interpreted as the beginning of today in
270270
local time, because the application was not configured to use UTC times.
271271

272+
.. note::
273+
274+
When the database contains a string value for a ``Time`` field, Mongoid
275+
parses the string value using ``Time.parse`` which considers values without
276+
time zones to be in local time.
277+
272278

273279
.. _field-type-date:
274280

@@ -295,6 +301,13 @@ recommended to explicitly convert ``String``, ``Time`` and ``DateTime``
295301
objects to ``Date`` objects before assigning the values to fields of type
296302
``Date``.
297303

304+
.. note::
305+
306+
When the database contains a string value for a ``Date`` field, Mongoid
307+
parses the string value using ``Time.parse``, discards the time portion of
308+
the resulting ``Time`` object and uses the date portion. ``Time.parse``
309+
considers values without time zones to be in local time.
310+
298311

299312
.. _field-type-date-time:
300313

@@ -364,6 +377,12 @@ If a time zone is specified, it is respected:
364377
ticket.opened_at
365378
# => Sun, 04 Mar 2018 09:00:00 +0000
366379

380+
.. note::
381+
382+
When the database contains a string value for a ``DateTime`` field, Mongoid
383+
parses the string value using ``Time.parse`` which considers values without
384+
time zones to be in local time.
385+
367386

368387
.. _field-type-regexp:
369388

0 commit comments

Comments
 (0)