[Git][debian-gis-team/cftime][master] 4 commits: New upstream version 1.1.3+ds

Bas Couwenberg gitlab at salsa.debian.org
Thu May 14 05:13:27 BST 2020



Bas Couwenberg pushed to branch master at Debian GIS Project / cftime


Commits:
62ff8e58 by Bas Couwenberg at 2020-05-14T06:04:02+02:00
New upstream version 1.1.3+ds
- - - - -
670c60fa by Bas Couwenberg at 2020-05-14T06:04:02+02:00
Update upstream source from tag 'upstream/1.1.3+ds'

Update to upstream version '1.1.3+ds'
with Debian dir 5b989b8b4a2feb07507ec5badc60b4f660e05fff
- - - - -
46a84087 by Bas Couwenberg at 2020-05-14T06:04:33+02:00
New upstream release.

- - - - -
2627cd70 by Bas Couwenberg at 2020-05-14T06:05:05+02:00
Set distribution to unstable.

- - - - -


5 changed files:

- Changelog
- README.md
- cftime/_cftime.pyx
- debian/changelog
- test/test_cftime.py


Changes:

=====================================
Changelog
=====================================
@@ -1,3 +1,9 @@
+version 1.1.3 (release tag v1.1.3rel)
+=====================================
+ * add isoformat method for compatibility with python datetime (issue #152).
+ * make 'standard' default calendar for cftime.datetime
+   so that dayofwk,dayofyr methods don't fail (issue #169).
+
 version 1.1.2 (release tag v1.1.2rel)
 =====================================
  * change dayofwk and dayofyr attributes into properties (issue #158)


=====================================
README.md
=====================================
@@ -12,7 +12,11 @@ Time-handling functionality from netcdf4-python
 ## News
 For details on the latest updates, see the [Changelog](https://github.com/Unidata/cftime/blob/master/Changelog).
 
-4/20/2020:  version 1.1.2 released.  Code optimization, fix logic so `only_use_cftime_datimes=False` works as expected (issues #158 and #165).
+5/12/2020:  version 1.1.3 released.  Add isoformat method for compatibility with python datetime (issue #152).
+ Make 'standard' default calendar for cftime.datetime so that dayofwk,dayofyr methods don't fail (issue #169).
+
+4/20/2020:  version 1.1.2 released.  Code optimization, fix logic so `only_use_cftime_datimes=False` works as 
+ expected (issues [#158](https://github.com/Unidata/cftime/issues/158) and [#165](https://github.com/Unidata/cftime/issues/165)).
 
 3/16/2020:  version 1.1.1 released.  Fix bug in microsecond formatting, ensure identical num2date results if input is an array of times, or a single scalar ([issue #143](https://github.com/Unidata/cftime/issues/143)).
 


=====================================
cftime/_cftime.pyx
=====================================
@@ -52,7 +52,7 @@ cdef int32_t* days_per_month_array = [
 _rop_lookup = {Py_LT: '__gt__', Py_LE: '__ge__', Py_EQ: '__eq__',
                Py_GT: '__lt__', Py_GE: '__le__', Py_NE: '__ne__'}
 
-__version__ = '1.1.2'
+__version__ = '1.1.3'
 
 # Adapted from http://delete.me.uk/2005/03/iso8601.html
 # Note: This regex ensures that all ISO8601 timezone formats are accepted - but, due to legacy support for other timestrings, not all incorrect formats can be rejected.
@@ -161,7 +161,7 @@ cdef _parse_date_and_units(timestr,calendar='standard'):
     # parse the date string.
     year, month, day, hour, minute, second, microsecond, utc_offset = _parse_date(
         isostring.strip())
-    return units, utc_offset, datetime(year, month, day, hour, minute, second)
+    return units, utc_offset, datetime(year, month, day, hour, minute, second, calendar=calendar)
 
 
 def date2num(dates,units,calendar='standard'):
@@ -1254,7 +1254,7 @@ Gregorial calendar.
 
     def __init__(self, int year, int month, int day, int hour=0, int minute=0,
                        int second=0, int microsecond=0, int dayofwk=-1, 
-                       int dayofyr = -1):
+                       int dayofyr = -1, calendar='standard'):
 
         self.year = year
         self.month = month
@@ -1263,7 +1263,7 @@ Gregorial calendar.
         self.minute = minute
         self.second = second
         self.microsecond = microsecond
-        self.calendar = ""
+        self.calendar = calendar
         self.datetime_compatible = True
         self._dayofwk = dayofwk
         self._dayofyr = dayofyr
@@ -1353,12 +1353,29 @@ Gregorial calendar.
                                      str(self))
 
     def __str__(self):
-        second = '{:02d}'.format(self.second)
-        if self.microsecond:
-            second += '.{:06d}'.format(self.microsecond)
-
-        return "{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{}".format(
-            self.year, self.month, self.day, self.hour, self.minute, second)
+        return self.isoformat(' ')
+
+    def isoformat(self,sep='T',timespec='auto'):
+        second = ":%02i" %self.second
+        if (timespec == 'auto' and self.microsecond) or timespec == 'microseconds':
+            second += ".%06i" % self.microsecond
+        if timespec == 'milliseconds':
+            millisecs = self.microsecond/1000
+            second += ".%03i" % millisecs
+        if timespec in ['auto', 'microseconds', 'milliseconds']:
+            return "%04i-%02i-%02i%s%02i:%02i%s" %\
+            (self.year, self.month, self.day, sep, self.hour, self.minute, second)
+        elif timespec == 'seconds':
+            return "%04i-%02i-%02i%s%02i:%02i:%02i" %\
+            (self.year, self.month, self.day, sep, self.hour, self.minute, self.second)
+        elif timespec == 'minutes':
+            return "%04i-%02i-%02i%s%02i:%02i" %\
+            (self.year, self.month, self.day, sep, self.hour, self.minute)
+        elif timespec == 'hours':
+            return "%04i-%02i-%02i%s%02i" %\
+            (self.year, self.month, self.day, sep, self.hour)
+        else:
+            raise ValueError('illegal timespec')
 
     def __hash__(self):
         try:


=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+cftime (1.1.3+ds-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Thu, 14 May 2020 06:04:57 +0200
+
 cftime (1.1.2+ds-1) unstable; urgency=medium
 
   * New upstream release.


=====================================
test/test_cftime.py
=====================================
@@ -744,9 +744,20 @@ class cftimeTestCase(unittest.TestCase):
         d = cftime.num2date(1261440000.015625,units)
         # on windows only 100 ms precision
         assert(str(d)[0:24] == '2009-12-22 00:00:00.0156')
+        # issue #152 add isoformat()
+        assert(d.isoformat()[0:24] == '2009-12-22T00:00:00.0156')
+        assert(d.isoformat(sep=' ')[0:24] == '2009-12-22 00:00:00.0156')
+        assert(d.isoformat(sep=' ',timespec='milliseconds') == '2009-12-22 00:00:00.015')
+        assert(d.isoformat(sep=' ',timespec='seconds') == '2009-12-22 00:00:00')
+        assert(d.isoformat(sep=' ',timespec='minutes') == '2009-12-22 00:00')
+        assert(d.isoformat(sep=' ',timespec='hours') == '2009-12-22 00')
         # issue #165: make sure python datetime returned
         d=num2date(0,units="seconds since 2000-01-01 00:00:00",only_use_cftime_datetimes=False)
         assert isinstance(d, datetime)
+        # issue #169: cftime.datetime has no calendar attribute, causing dayofwk,dayofyr methods
+        # to fail.
+        c = cftime.datetime(*cftime._parse_date('7480-01-01 00:00:00'))
+        assert(c.strftime() == '7480-01-01 00:00:00')
 
 class TestDate2index(unittest.TestCase):
 



View it on GitLab: https://salsa.debian.org/debian-gis-team/cftime/-/compare/ad3fed7d8492bf8859c9454d727b3090001a9040...2627cd70a381b9156a58cfb14f7e51eb9d900132

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/cftime/-/compare/ad3fed7d8492bf8859c9454d727b3090001a9040...2627cd70a381b9156a58cfb14f7e51eb9d900132
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200514/4e17f021/attachment-0001.html>


More information about the Pkg-grass-devel mailing list