diff --git a/ChangeLog b/ChangeLog index fbfa7f1..fbe2b4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -2019-05-29 +2019-07-01 * Version 1.7.0 released ======================== + Add GTime.datetime() method and add optional precision to GTime.utc() (#2909) + 2019-06-05 diff --git a/NEWS b/NEWS index 9b9e99b..38142d4 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in GammaLib 1.7.0 -5 June 2019 +1 July 2019 1. Introduction @@ -21,7 +21,7 @@ The following classes have been renamed: - none The following methods have been added: -- none +- GTime.datetime() - Datetime conversion in Python interface The following methods have been removed: - none @@ -30,7 +30,7 @@ The following methods have been renamed: - none The arguments for the following methods have been changed: -- none +- GTime::utc(const int& precision=0) - Add optional precision value The return value of the following methods has been changed: - none @@ -73,7 +73,9 @@ None 10. Observation module ---------------------- -None +Add GTime.datetime() method to the Python interface to convert times from and +to datetime.datetime objects. Add an optional precision argument to the GTime.utc() +to set the number of digits after the comma for the seconds (#2909). 11. Optimization module diff --git a/doc/source/admin/release_history/1.7.rst b/doc/source/admin/release_history/1.7.rst index 0bf523c..5b441f1 100644 --- a/doc/source/admin/release_history/1.7.rst +++ b/doc/source/admin/release_history/1.7.rst @@ -22,6 +22,8 @@ Bug fixes Improvements ------------ +* [`2909 `_] - + Add GTime.datetime() method and add optional precision to GTime.utc() method. New features diff --git a/test/test_GObservation.cpp b/test/test_GObservation.cpp index d7ed92c..45219ea 100644 --- a/test/test_GObservation.cpp +++ b/test/test_GObservation.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_GObservation.cpp - Test observation module * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2017 by Jean-Baptiste Cayrou * + * copyright (C) 2012-2019 by Jean-Baptiste Cayrou * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -827,9 +827,8 @@ void TestGObservation::test_time(void) test_value(time.days("TT"), 1.4288979); test_value(time.days("TAI"), 1.4285254); // TAI=TT-0.0003725 test_value(time.days("UTC"), 1.42813188); // UTC=TT-0.00076602 - test_assert(time.utc() == "2010-01-02T10:17:37", - "GTime::utc(): 2010-01-02T10:17:37 expected, "+ - time.utc()+" found."); + test_value(time.utc(), "2010-01-02T10:17:37"); + test_value(time.utc(2), "2010-01-02T10:17:36.79"); // Test set method. The UTC conversion to MJD (TT) was done using xTime. // Note that xTime missed a second for the "2006-01-01T00:00:00" diff --git a/test/test_GObservation.py b/test/test_GObservation.py index eeb20ae..cba03c9 100755 --- a/test/test_GObservation.py +++ b/test/test_GObservation.py @@ -1,7 +1,7 @@ # ========================================================================== # This module performs unit tests for the GammaLib observation module. # -# Copyright (C) 2012-2018 Juergen Knoedlseder +# Copyright (C) 2012-2019 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -474,6 +474,16 @@ class Test(gammalib.GPythonTestSuite): self.test_assert(time_a >= time_b, 'Check larger or equal than operator') + # Get datetime + self.test_value(str(time_a.datetime()), '2010-01-01 00:00:09.000001', + 'Check datetime getter method') + + # Set datetime + time_dt = gammalib.GTime() + time_dt.datetime(time_a.datetime()) + self.test_value(time_dt.secs(), 9.0, 1.0e-6, + 'Check datetime setter method') + # Return return