Commit 39d937d5236d34d9ae84869d7d0b449ad0509f48

Authored by Jürgen Knödlseder
1 parent baa445b9

Integrate code and add unit tests

ChangeLog
1   -2019-05-29
  1 +2019-07-01
2 2  
3 3 * Version 1.7.0 released
4 4 ========================
5 5  
  6 + Add GTime.datetime() method and add optional precision to GTime.utc() (#2909)
  7 +
6 8  
7 9 2019-06-05
8 10  
... ...
1 1 New Features and Important Changes in GammaLib 1.7.0
2 2  
3   -5 June 2019
  3 +1 July 2019
4 4  
5 5  
6 6 1. Introduction
... ... @@ -21,7 +21,7 @@ The following classes have been renamed:
21 21 - none
22 22  
23 23 The following methods have been added:
24   -- none
  24 +- GTime.datetime() - Datetime conversion in Python interface
25 25  
26 26 The following methods have been removed:
27 27 - none
... ... @@ -30,7 +30,7 @@ The following methods have been renamed:
30 30 - none
31 31  
32 32 The arguments for the following methods have been changed:
33   -- none
  33 +- GTime::utc(const int& precision=0) - Add optional precision value
34 34  
35 35 The return value of the following methods has been changed:
36 36 - none
... ... @@ -73,7 +73,9 @@ None
73 73  
74 74 10. Observation module
75 75 ----------------------
76   -None
  76 +Add GTime.datetime() method to the Python interface to convert times from and
  77 +to datetime.datetime objects. Add an optional precision argument to the GTime.utc()
  78 +to set the number of digits after the comma for the seconds (#2909).
77 79  
78 80  
79 81 11. Optimization module
... ...
doc/source/admin/release_history/1.7.rst
... ... @@ -22,6 +22,8 @@ Bug fixes
22 22 Improvements
23 23 ------------
24 24  
  25 +* [`2909 <https://cta-redmine.irap.omp.eu/issues/2909>`_] -
  26 + Add GTime.datetime() method and add optional precision to GTime.utc() method.
25 27  
26 28  
27 29 New features
... ...
test/test_GObservation.cpp
1 1 /***************************************************************************
2 2 * test_GObservation.cpp - Test observation module *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2017 by Jean-Baptiste Cayrou *
  4 + * copyright (C) 2012-2019 by Jean-Baptiste Cayrou *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -827,9 +827,8 @@ void TestGObservation::test_time(void)
827 827 test_value(time.days("TT"), 1.4288979);
828 828 test_value(time.days("TAI"), 1.4285254); // TAI=TT-0.0003725
829 829 test_value(time.days("UTC"), 1.42813188); // UTC=TT-0.00076602
830   - test_assert(time.utc() == "2010-01-02T10:17:37",
831   - "GTime::utc(): 2010-01-02T10:17:37 expected, "+
832   - time.utc()+" found.");
  830 + test_value(time.utc(), "2010-01-02T10:17:37");
  831 + test_value(time.utc(2), "2010-01-02T10:17:36.79");
833 832  
834 833 // Test set method. The UTC conversion to MJD (TT) was done using xTime.
835 834 // Note that xTime missed a second for the "2006-01-01T00:00:00"
... ...
test/test_GObservation.py
1 1 # ==========================================================================
2 2 # This module performs unit tests for the GammaLib observation module.
3 3 #
4   -# Copyright (C) 2012-2018 Juergen Knoedlseder
  4 +# Copyright (C) 2012-2019 Juergen Knoedlseder
5 5 #
6 6 # This program is free software: you can redistribute it and/or modify
7 7 # it under the terms of the GNU General Public License as published by
... ... @@ -474,6 +474,16 @@ class Test(gammalib.GPythonTestSuite):
474 474 self.test_assert(time_a >= time_b,
475 475 'Check larger or equal than operator')
476 476  
  477 + # Get datetime
  478 + self.test_value(str(time_a.datetime()), '2010-01-01 00:00:09.000001',
  479 + 'Check datetime getter method')
  480 +
  481 + # Set datetime
  482 + time_dt = gammalib.GTime()
  483 + time_dt.datetime(time_a.datetime())
  484 + self.test_value(time_dt.secs(), 9.0, 1.0e-6,
  485 + 'Check datetime setter method')
  486 +
477 487 # Return
478 488 return
479 489  
... ...