changeset 6515e46baf6c in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset;node=6515e46baf6c
description:
        PYSON's DateTime defaults to the current time in UTC

        issue9698
        review329211002
        (grafted from 662ae82c0f5e83f6e4147cb6ef59917e5e182d45)
diffstat:

 doc/ref/pyson.rst |  4 +++-
 trytond/pyson.py  |  2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r fc3a251dae3a -r 6515e46baf6c doc/ref/pyson.rst
--- a/doc/ref/pyson.rst Wed Oct 21 23:23:17 2020 +0200
+++ b/doc/ref/pyson.rst Thu Oct 22 12:11:09 2020 +0200
@@ -218,10 +218,12 @@
 the *arguments* explained below.
 Missing values of arguments named by  ``year``, ``month``, ``day``, ``hour``,
 ``minute``, ``second``, ``microseconds`` take their defaults from ``start`` or
-the actual date and time.
+the actual date and time in `UTC`_.
 When values of arguments named by ``delta_*`` are given, these are added  to
 the appropriate attributes in a date and time preserving manner.
 
+.. _`UTC`: https://en.wikipedia.org/wiki/Coordinated_Universal_Time
+
 Arguments:
 
 ``year``
diff -r fc3a251dae3a -r 6515e46baf6c trytond/pyson.py
--- a/trytond/pyson.py  Wed Oct 21 23:23:17 2020 +0200
+++ b/trytond/pyson.py  Thu Oct 22 12:11:09 2020 +0200
@@ -630,7 +630,7 @@
                 and not isinstance(now, datetime.datetime)):
             now = datetime.datetime.combine(now, datetime.time())
         if not isinstance(now, datetime.datetime):
-            now = datetime.datetime.now()
+            now = datetime.datetime.utcnow()
         return now + relativedelta(
             year=dct['y'],
             month=dct['M'],

Reply via email to