Repository: NCAS-CMS/cfunits

Issue:
Change default calendar from "gregorian" to "standard"
The `gregorian` calendar was deprecated as of CF-1.9

Discussion:

Patch:
diff --git a/Changelog.rst b/Changelog.rst
index 7bb43a9..120d111 100644
--- a/Changelog.rst
+++ b/Changelog.rst
@@ -1,3 +1,12 @@
+version 3.3.5
+-------------
+----
+
+**2022-09-??**
+
+* Change default calendar from ``'gregorian'`` to ``'standard'``
+  (https://github.com/NCAS-CMS/cfunits/issues/45)
+
 version 3.3.4
 -------------
 ----
diff --git a/cfunits/units.py b/cfunits/units.py
index 6faf08e..0848618 100644
--- a/cfunits/units.py
+++ b/cfunits/units.py
@@ -319,11 +319,11 @@ _cached_ut_unit["1"] = _dimensionless_unit_one
 # --------------------------------------------------------------------
 # Set the default calendar type according to the CF conventions
 # --------------------------------------------------------------------
-_default_calendar = "gregorian"
+_default_calendar = "standard"
 _canonical_calendar = {
-    "gregorian": "gregorian",
-    "standard": "gregorian",
-    "none": "gregorian",
+    "gregorian": "standard",
+    "standard": "standard",
+    "none": "standard",
     "proleptic_gregorian": "proleptic_gregorian",
     "360_day": "360_day",
     "noleap": "365_day",
@@ -583,9 +583,9 @@ class Units:
     Traceback (most recent call last):
         ...
     AttributeError: Units has no attribute 'calendar'
-    >>> v = Units('days since 2000-1-1', 'gregorian')
+    >>> v = Units('days since 2000-1-1', 'standard')
     >>> v.calendar
-    'gregorian'
+    'standard'
     >>> v.equals(u)
     True
 
@@ -880,10 +880,10 @@ class Units:
 
         **Examples:**
 
-        >>> u = Units('days since 3-4-5', calendar='gregorian')
+        >>> u = Units('days since 3-4-5', calendar='standard')
         >>> u.__getstate__()
         {'_units': 'days since 3-4-5',
-         '_calendar': 'gregorian'}
+         '_calendar': 'standard'}
 
         """
         return dict(
@@ -1818,7 +1818,7 @@ class Units:
 
         >>> u = Units('days since 2000-1-1')
         >>> v = Units('days since 2000-1-1', calendar='366_day')
-        >>> w = Units('seconds since 1978-3-12', calendar='gregorian')
+        >>> w = Units('seconds since 1978-3-12', calendar='standard')
 
         >>> u.equivalent(v)
         False
diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst
index 0598c25..8d564b1 100644
--- a/docs/source/contributing.rst
+++ b/docs/source/contributing.rst
@@ -106,5 +106,6 @@ ideas, code, and documentation to the cfunits library:
 * Daniel Mohr
 * David Hassell
 * Gareth Jones
+* Lars Bärring
 * Jonathan Gregory
 * Sadie Bartholomew  


Test patch:
diff --git a/cfunits/test/test_Units.py b/cfunits/test/test_Units.py
index 6a01754..241d7b0 100644
--- a/cfunits/test/test_Units.py
+++ b/cfunits/test/test_Units.py
@@ -32,7 +32,7 @@ class UnitsTest(unittest.TestCase):
 
         self.assertEqual(
             Units("days since 2000-1-1"),
-            Units("d since 2000-1-1 0:0", calendar="gregorian"),
+            Units("d since 2000-1-1 0:0", calendar="standard"),
         )
         self.assertEqual(
             Units("days since 2000-1-1"),
@@ -104,7 +104,7 @@ class UnitsTest(unittest.TestCase):
         )
         self.assertTrue(
             Units("days since 2000-1-1").equivalent(
-                Units("d since 2000-1-1 0:0", calendar="gregorian")
+                Units("d since 2000-1-1 0:0", calendar="standard")
             )
         )
         self.assertTrue(
@@ -129,7 +129,7 @@ class UnitsTest(unittest.TestCase):
         self.assertNotEqual(u, v)
 
         u = Units("days since 2000-02-02", calendar="standard")
-        v = Units("months since 2000-02-02", calendar="gregorian")
+        v = Units("months since 2000-02-02", calendar="standard")
         self.assertNotEqual(u, v)
 
         self.assertFalse(Units(1).equivalent(Units(1)))
@@ -386,8 +386,10 @@ class UnitsTest(unittest.TestCase):
         u = Units("hours since 2100-1-1", calendar="noleap")
         self.assertEqual(u.formatted(), "h since 2100-01-01 00:00:00")
 
-
-# --- End: class
+    def test_Units_default_calendar(self):
+        """Tests the default calendar on `Units`."""
+        u = Units("days since 2000-01-01")
+        self.assertEqual(u._canonical_calendar, "standard")
 
 
 if __name__ == "__main__":