Skip to content

Commit 6c1a3d3

Browse files
p-mongop
andauthored
RUBY-2179 Document that dates are serialized as midnight in UTC (#214)
* RUBY-2179 Document that dates are serialized as midnight in UTC * RUBY-2187 document DateTime conversion to Gregorian calendar prior to serialization * remove the Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 5ee7569 commit 6c1a3d3

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

docs/tutorials/bson-v4.txt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,30 @@ all time calculations using integer math, as inexactness of floating point
588588
calculations may produce unexpected results.
589589

590590

591-
Date And DateTime Instances
592-
---------------------------
591+
DateTime Instances
592+
------------------
593593

594594
BSON only supports storing the time as the number of seconds since the
595-
Unix epoch. Ruby's ``Date`` and ``DateTime`` instances can be serialized
596-
to BSON, but when the BSON is deserialized the times will be returned as
595+
Unix epoch. Ruby's ``DateTime`` instances can be serialized to BSON,
596+
but when the BSON is deserialized the times will be returned as
597597
``Time`` instances.
598598

599+
``DateTime`` class in Ruby supports non-Gregorian calendars. When non-Gregorian
600+
``DateTime`` instances are serialized, they are first converted to Gregorian
601+
calendar, and the respective date in the Gregorian calendar is stored in the
602+
database.
603+
604+
605+
Date Instances
606+
--------------
607+
608+
BSON only supports storing the time as the number of seconds since the
609+
Unix epoch. Ruby's ``Date`` instances can be serialized to BSON, but when
610+
the BSON is deserialized the times will be returned as ``Time`` instances.
611+
612+
When ``Date`` instances are serialized, the time value used is midnight
613+
of the day that the ``Date`` refers to in UTC.
614+
599615

600616
Regular Expressions
601617
-------------------

0 commit comments

Comments
 (0)