diff --git a/Changelog b/Changelog index 6c206aa1..5a737acd 100644 --- a/Changelog +++ b/Changelog @@ -5,19 +5,10 @@ version 1.5.0 (not yet released) (via `cftime.datetime.__format__`) PR #232. * add support for astronomical year numbering (including year zero) for real-world calendars using 'has_year_zero' cftime.datetime kwarg (PR #234). - Default is False for 'julian','gregorian'/'standard', but True - for 'proleptic_gregorian' (since ISO 8601 has a year zero). - The change for proleptic_gregorian is not backwards-compatible, users - who have been employing dates before 1-1-1 must now set has_year_zero=False - explicitly. - The calendar-specific defaults conform to the proposed updated CF standard - (https://github.com/cf-convention/cf-conventions/issues/298). + Default is False for 'real-world' calendars and True + for idealized calendars. Ignored for idealized calendars like '360_day' - (they always have year zero). Strictly speaking, CF - does not allow for dates before 1-1-1 in the 'julian' - or 'gregorian'/'standard' calendars, or dates before 1-1-1 in - the 'proleptic_gregorian' calendar without a year zero, but cftime will - but will issue a warning without raising an exception. + (they always have year zero). * add "change_calendar" cftime.datetime method to switch to another 'real-world' calendar. Enable comparison of cftime.datetime instances with different 'real-world' calendars (using the new change_calendar method) diff --git a/docs/_build/doctrees/api.doctree b/docs/_build/doctrees/api.doctree index 1acc4a1d..5721e137 100644 Binary files a/docs/_build/doctrees/api.doctree and b/docs/_build/doctrees/api.doctree differ diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index e7c3934c..c83d8c84 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree index 50e66293..3a442cc6 100644 Binary files a/docs/_build/doctrees/index.doctree and b/docs/_build/doctrees/index.doctree differ diff --git a/docs/_build/doctrees/installing.doctree b/docs/_build/doctrees/installing.doctree index fa1ff1c8..ca2c5c47 100644 Binary files a/docs/_build/doctrees/installing.doctree and b/docs/_build/doctrees/installing.doctree differ diff --git a/docs/_build/html/_static/basic.css b/docs/_build/html/_static/basic.css index 24a49f09..be19270e 100644 --- a/docs/_build/html/_static/basic.css +++ b/docs/_build/html/_static/basic.css @@ -4,7 +4,7 @@ * * Sphinx stylesheet -- basic theme. * - * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/_build/html/_static/doctools.js b/docs/_build/html/_static/doctools.js index 7d88f807..144884ea 100644 --- a/docs/_build/html/_static/doctools.js +++ b/docs/_build/html/_static/doctools.js @@ -4,7 +4,7 @@ * * Sphinx JavaScript utilities for all documentation. * - * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/_build/html/_static/language_data.js b/docs/_build/html/_static/language_data.js index d2b4ee91..0e7dc7e9 100644 --- a/docs/_build/html/_static/language_data.js +++ b/docs/_build/html/_static/language_data.js @@ -5,7 +5,7 @@ * This script contains the language-specific data used by searchtools.js, * namely the list of stopwords, stemmer, scorer and splitter. * - * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/_build/html/_static/pygments.css b/docs/_build/html/_static/pygments.css index f346859c..de7af262 100644 --- a/docs/_build/html/_static/pygments.css +++ b/docs/_build/html/_static/pygments.css @@ -1,4 +1,4 @@ -pre { line-height: 125%; margin: 0; } +pre { line-height: 125%; } td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } diff --git a/docs/_build/html/_static/searchtools.js b/docs/_build/html/_static/searchtools.js index 261ecaa9..6fc9e7f3 100644 --- a/docs/_build/html/_static/searchtools.js +++ b/docs/_build/html/_static/searchtools.js @@ -4,7 +4,7 @@ * * Sphinx JavaScript utilities for the full-text search. * - * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/_build/html/api.html b/docs/_build/html/api.html index da4bea8b..2dc21888 100644 --- a/docs/_build/html/api.html +++ b/docs/_build/html/api.html @@ -12,7 +12,6 @@ - @@ -59,10 +58,8 @@ is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. -The defaults are set to conform with -CF conventions (False for ‘julian’, ‘gregorian’/’standard’, True -for ‘proleptic_gregorian’ (ISO 8601) and True for the idealized -calendars ‘noleap’/’365_day’, ‘360_day’, 366_day’/’all_leap’) +The defaults are False for real-world calendars +and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -100,10 +97,8 @@ is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. -The defaults are set to conform with -CF conventions (False for ‘julian’, ‘gregorian’/’standard’, True -for ‘proleptic_gregorian’ (ISO 8601) and True for the idealized -calendars ‘noleap’/’365_day’, ‘360_day’, 366_day’/’all_leap’) +The defaults are False for real-world calendars +and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -137,10 +132,8 @@ is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. -The defaults are set to conform with -CF conventions (False for ‘julian’, ‘gregorian’/’standard’, True -for ‘proleptic_gregorian’ (ISO 8601) and True for the idealized -calendars ‘noleap’/’365_day’, ‘360_day’, 366_day’/’all_leap’) +The defaults are False for real-world calendars +and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -152,11 +145,20 @@ instances.

The default format of the string produced by strftime is controlled by self.format (default %Y-%m-%d %H:%M:%S).

+
+
+change_calendar(self, calendar, has_year_zero=None)
+
+
static fromordinal(jday, calendar='standard', has_year_zero=None)

Create a datetime instance from a julian day ordinal, calendar -and (optionally) year zero convention (inverse of toordinal).

+and (optionally) year zero convention (inverse of toordinal). The +Julian day number is the number of days since noon UTC January 1, 4713 +in the proleptic julian calendar with no year zero (November 24, 4713 +in the proleptic gregorian calendar that includes the year zero). For +idealized calendars, the origin is noon UTC of the year zero.

@@ -234,10 +236,8 @@ is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. -The defaults are set to conform with -CF conventions (False for ‘julian’, ‘gregorian’/’standard’, True -for ‘proleptic_gregorian’ (ISO 8601) and True for the idealized -calendars ‘noleap’/’365_day’, ‘360_day’, 366_day’/’all_leap’) +The defaults are False for real-world calendars +and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -347,7 +347,7 @@

Quick search

©2018, Jeff Whitaker. | - Powered by Sphinx 3.3.1 + Powered by Sphinx 3.4.3 & Alabaster 0.7.12 | diff --git a/docs/_build/html/genindex.html b/docs/_build/html/genindex.html index 0ebb3553..10adce39 100644 --- a/docs/_build/html/genindex.html +++ b/docs/_build/html/genindex.html @@ -12,7 +12,6 @@ - @@ -57,6 +56,10 @@

C

+

D

@@ -200,7 +203,7 @@

Quick search

©2018, Jeff Whitaker. | - Powered by Sphinx 3.3.1 + Powered by Sphinx 3.4.3 & Alabaster 0.7.12 diff --git a/docs/_build/html/index.html b/docs/_build/html/index.html index 7a7cd291..6f9cc406 100644 --- a/docs/_build/html/index.html +++ b/docs/_build/html/index.html @@ -12,7 +12,6 @@ - @@ -116,7 +115,7 @@

Quick search

©2018, Jeff Whitaker. | - Powered by Sphinx 3.3.1 + Powered by Sphinx 3.4.3 & Alabaster 0.7.12 | diff --git a/docs/_build/html/installing.html b/docs/_build/html/installing.html index 2f9a850a..d85dd985 100644 --- a/docs/_build/html/installing.html +++ b/docs/_build/html/installing.html @@ -12,7 +12,6 @@ - @@ -132,7 +131,7 @@

Quick search

©2018, Jeff Whitaker. | - Powered by Sphinx 3.3.1 + Powered by Sphinx 3.4.3 & Alabaster 0.7.12 | diff --git a/docs/_build/html/objects.inv b/docs/_build/html/objects.inv index cf931c0a..a2668cb0 100644 Binary files a/docs/_build/html/objects.inv and b/docs/_build/html/objects.inv differ diff --git a/docs/_build/html/py-modindex.html b/docs/_build/html/py-modindex.html index 1e18565a..b7f0e787 100644 --- a/docs/_build/html/py-modindex.html +++ b/docs/_build/html/py-modindex.html @@ -12,7 +12,6 @@ - @@ -111,7 +110,7 @@

Quick search

©2018, Jeff Whitaker. | - Powered by Sphinx 3.3.1 + Powered by Sphinx 3.4.3 & Alabaster 0.7.12 diff --git a/docs/_build/html/search.html b/docs/_build/html/search.html index b5a05810..32ff16a1 100644 --- a/docs/_build/html/search.html +++ b/docs/_build/html/search.html @@ -13,8 +13,8 @@ - + @@ -102,7 +102,7 @@

Related Topics

©2018, Jeff Whitaker. | - Powered by Sphinx 3.3.1 + Powered by Sphinx 3.4.3 & Alabaster 0.7.12 diff --git a/docs/_build/html/searchindex.js b/docs/_build/html/searchindex.js index 898445ce..792f8556 100644 --- a/docs/_build/html/searchindex.js +++ b/docs/_build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api","index","installing"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.intersphinx":1,sphinx:56},filenames:["api.rst","index.rst","installing.rst"],objects:{"":{cftime:[0,0,0,"-"]},"cftime.datetime":{fromordinal:[0,3,1,""],isoformat:[0,3,1,""],replace:[0,3,1,""],strftime:[0,3,1,""],timetuple:[0,3,1,""],toordinal:[0,3,1,""]},cftime:{date2index:[0,1,1,""],date2num:[0,1,1,""],datetime:[0,2,1,""],num2date:[0,1,1,""],num2pydate:[0,1,1,""],time2index:[0,1,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method"},terms:{"100":[],"1582":0,"1st":0,"360_dai":0,"365_dai":0,"366_dai":0,"4712":0,"4713":0,"4714":0,"8601":0,"boolean":[],"class":0,"default":[0,2],"int":0,"new":[0,2],"return":0,"static":0,"true":0,For:0,Has:0,The:[0,2],Then:2,__add__:0,__format__:0,__repr__:0,__str__:0,__sub__:0,_cftime:[],accuraci:0,after:0,all:0,all_leap:0,allow:0,allowd:0,also:2,alwai:0,api:1,appear:2,appli:0,approxim:0,arg:[],argument:0,arrai:0,associ:0,assum:0,astronom:0,attribut:0,auto:0,awar:0,base:0,befor:[0,2],behavior:0,being:2,between:0,blank:0,breakpoint:0,build:2,build_ext:2,calcul:0,calendar:0,can:0,cannot:0,cartopi:2,cfconvent:[],cftime:[0,2],chang:2,channel:2,check:2,climat:1,clone:2,closest:0,command:2,commun:2,compar:[],comparison:0,complet:0,comput:[],conda:2,conform:[0,1],contain:0,control:0,convent:[0,1],correspond:0,creat:0,ctime:0,current:0,cython:2,dai:0,date2index:0,date2num:0,date:0,datefromjuliandai:[],datetim:0,datetimeallleap:[],datetimegregorian:[],datetimejulian:[],datetimenoleap:[],datetimeprolepticgregorian:[],dayofwk:0,dayofyr:0,daysinmonth:0,decod:1,defin:0,depend:1,describ:0,determin:[],develop:1,differ:[],difficult:2,direct:0,document:0,don:2,dst:0,easiest:2,either:0,entri:0,equival:0,error:0,even:0,everyth:2,exact:0,exist:0,explicit:0,extens:2,fall:[],fals:0,field:0,file:1,first:[0,2],flag:0,follow:[],forecast:1,forg:2,form:0,format:0,found:0,fraction:0,from:0,fromordin:0,get:2,github:2,given:0,gregorian:0,has_year_zero:0,have:[0,2],histor:0,hour:0,http:[],ideal:0,ignor:0,includ:0,increas:0,index:[0,1],indic:0,inplac:2,input:0,instal:1,instanc:0,instruct:1,integ:0,invers:0,iso:0,isoformat:0,its:0,januari:0,jdai:0,julian:0,juliandayfromd:[],just:0,keyword:0,kwarg:0,last:[],later:2,librari:1,like:[],line:2,list:0,localtim:0,mai:2,maintain:2,match:0,mean:0,metadata:0,method:0,microsecond:0,millisecond:0,mimic:0,minut:0,mix:0,modul:1,month:0,months_sinc:0,must:0,nativ:0,nctime:0,nearest:0,need:[0,2],netcdf:[0,1],no_leap:[],noleap:0,none:0,noon:0,note:0,novemb:0,num2dat:0,num2pyd:0,number:0,numer:0,numpi:2,object:0,offset:0,one:0,onli:0,only_use_cftime_datetim:0,only_use_python_datetim:0,oper:0,option:0,order:0,ordin:0,org:[],origin:0,other:0,otherwis:0,over:0,overload:0,page:1,part:0,pass:2,perfectli:0,phoni:[],pip:2,place:2,possibl:0,preced:0,produc:0,prolept:0,proleptic_gregorian:0,pyarg:2,pynio:2,pytest:2,python:[0,1,2],rais:0,real:0,recommend:2,refer:0,releas:2,replac:0,repositori:2,repres:0,requir:1,return_tupl:[],ridden:0,rist:[],run:2,same:0,search:1,second:0,section:0,see:0,select:0,self:0,sep:0,sequenc:0,set:0,setup:2,should:0,sinc:0,some:0,specif:0,specifi:0,standard:0,start:0,store:0,strftime:0,string:0,strptime:0,struct_tim:0,subclass:0,subtract:[],suit:2,support:0,sure:2,synonym:0,system:0,test:2,than:0,thei:0,thi:0,time2index:0,time:[0,1],timedelta:0,timespec:0,timetupl:0,tool:2,toordin:0,unit:[0,1],unless:0,updat:2,use:[0,2],use_only_python_datetim:0,used:0,uses:[],using:[0,2],utc:0,valid:0,valu:[0,1],variabl:[0,1],versa:[],vice:[],wai:2,weekdai:0,when:2,where:0,whether:[],which:0,within:0,work:0,world:0,ydai:0,year:0,you:2,zero:0,zone:0},titles:["API","cftime","Installation"],titleterms:{api:0,cftime:1,content:1,depend:2,develop:2,indic:1,instal:2,instruct:2,requir:2,tabl:1}}) \ No newline at end of file +Search.setIndex({docnames:["api","index","installing"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.intersphinx":1,sphinx:56},filenames:["api.rst","index.rst","installing.rst"],objects:{"":{cftime:[0,0,0,"-"]},"cftime.datetime":{change_calendar:[0,3,1,""],fromordinal:[0,3,1,""],isoformat:[0,3,1,""],replace:[0,3,1,""],strftime:[0,3,1,""],timetuple:[0,3,1,""],toordinal:[0,3,1,""]},cftime:{date2index:[0,1,1,""],date2num:[0,1,1,""],datetime:[0,2,1,""],num2date:[0,1,1,""],num2pydate:[0,1,1,""],time2index:[0,1,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method"},terms:{"100":[],"1582":0,"1st":0,"360_dai":0,"365_dai":0,"366_dai":0,"4712":0,"4713":0,"4714":0,"8601":[],"boolean":[],"class":0,"default":[0,2],"int":0,"new":[0,2],"return":0,"static":0,"true":0,For:0,Has:0,The:[0,2],Then:2,__add__:0,__format__:0,__repr__:0,__str__:0,__sub__:0,_cftime:[],accuraci:0,after:0,all:0,all_leap:0,allow:0,allowd:0,also:2,alwai:0,api:1,appear:2,appli:0,approxim:0,arg:[],argument:0,arrai:0,associ:0,assum:0,astronom:0,attribut:0,auto:0,awar:0,base:0,befor:[0,2],behavior:0,being:2,between:0,blank:0,breakpoint:0,build:2,build_ext:2,calcul:0,calendar:0,can:0,cannot:0,cartopi:2,cfconvent:[],cftime:[0,2],chang:2,change_calendar:0,channel:2,check:2,climat:1,clone:2,closest:0,command:2,commun:2,compar:[],comparison:0,complet:0,comput:[],conda:2,conform:1,contain:0,control:0,convent:[0,1],correspond:0,creat:0,ctime:0,current:0,cython:2,dai:0,date2index:0,date2num:0,date:0,datefromjuliandai:[],datetim:0,datetimeallleap:[],datetimegregorian:[],datetimejulian:[],datetimenoleap:[],datetimeprolepticgregorian:[],dayofwk:0,dayofyr:0,daysinmonth:0,decod:1,defin:0,depend:1,describ:0,determin:[],develop:1,differ:[],difficult:2,direct:0,document:0,don:2,dst:0,easiest:2,either:0,entri:0,equival:0,error:0,even:0,everyth:2,exact:0,exist:0,explicit:0,extens:2,fall:[],fals:0,field:0,file:1,first:[0,2],flag:0,follow:[],forecast:1,forg:2,form:0,format:0,found:0,fraction:0,from:0,fromordin:0,get:2,github:2,given:0,gregorian:0,has_year_zero:0,have:[0,2],histor:0,hour:0,http:[],ideal:0,ignor:0,includ:0,increas:0,index:[0,1],indic:0,inplac:2,input:0,instal:1,instanc:0,instruct:1,integ:0,invers:0,iso:[],isoformat:0,its:0,januari:0,jdai:0,julian:0,juliandayfromd:[],just:0,keyword:0,kwarg:0,last:[],later:2,librari:1,like:[],line:2,list:0,localtim:0,mai:2,maintain:2,match:0,mean:0,metadata:0,method:0,microsecond:0,millisecond:0,mimic:0,minut:0,mix:0,modul:1,month:0,months_sinc:0,must:0,nativ:0,nctime:0,nearest:0,need:[0,2],netcdf:[0,1],no_leap:[],noleap:0,none:0,noon:0,note:0,novemb:0,num2dat:0,num2pyd:0,number:0,numer:0,numpi:2,object:0,offset:0,one:0,onli:0,only_use_cftime_datetim:0,only_use_python_datetim:0,oper:0,option:0,order:0,ordin:0,org:[],origin:0,other:0,otherwis:0,over:0,overload:0,page:1,part:0,pass:2,perfectli:0,phoni:[],pip:2,place:2,possibl:0,preced:0,produc:0,prolept:0,proleptic_gregorian:0,pyarg:2,pynio:2,pytest:2,python:[0,1,2],rais:0,real:0,recommend:2,refer:0,releas:2,replac:0,repositori:2,repres:0,requir:1,return_tupl:[],ridden:0,rist:[],run:2,same:0,search:1,second:0,section:0,see:0,select:0,self:0,sep:0,sequenc:0,set:0,setup:2,should:0,sinc:0,some:0,specif:0,specifi:0,standard:0,start:0,store:0,strftime:0,string:0,strptime:0,struct_tim:0,subclass:0,subtract:[],suit:2,support:0,sure:2,synonym:0,system:0,test:2,than:0,thei:0,thi:0,time2index:0,time:[0,1],timedelta:0,timespec:0,timetupl:0,tool:2,toordin:0,unit:[0,1],unless:0,updat:2,use:[0,2],use_only_python_datetim:0,used:0,uses:[],using:[0,2],utc:0,valid:0,valu:[0,1],variabl:[0,1],versa:[],vice:[],wai:2,weekdai:0,when:2,where:0,whether:[],which:0,within:0,work:0,world:0,ydai:0,year:0,you:2,zero:0,zone:0},titles:["API","cftime","Installation"],titleterms:{api:0,cftime:1,content:1,depend:2,develop:2,indic:1,instal:2,instruct:2,requir:2,tabl:1}}) \ No newline at end of file diff --git a/src/cftime/_cftime.pyx b/src/cftime/_cftime.pyx index 9aaffaf4..d7e0b9a6 100644 --- a/src/cftime/_cftime.pyx +++ b/src/cftime/_cftime.pyx @@ -156,10 +156,8 @@ def date2num(dates,units,calendar=None,has_year_zero=None): is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. - The defaults are set to conform with - CF conventions (False for 'julian', 'gregorian'/'standard', True - for 'proleptic_gregorian' (ISO 8601) and True for the idealized - calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap') + The defaults are False for real-world calendars + and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -456,10 +454,8 @@ def num2date( is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. - The defaults are set to conform with - CF conventions (False for 'julian', 'gregorian'/'standard', True - for 'proleptic_gregorian' (ISO 8601) and True for the idealized - calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap') + The defaults are False for real-world calendars + and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -564,10 +560,8 @@ def date2index(dates, nctime, calendar=None, select='exact', has_year_zero=None) is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. - The defaults are set to conform with - CF conventions (False for 'julian', 'gregorian'/'standard', True - for 'proleptic_gregorian' (ISO 8601) and True for the idealized - calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap') + The defaults are False for real-world calendars + and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -777,10 +771,8 @@ def _date2index(dates, nctime, calendar=None, select='exact', has_year_zero=None is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. - The defaults are set to conform with - CF conventions (False for 'julian', 'gregorian'/'standard', True - for 'proleptic_gregorian' (ISO 8601) and True for the idealized - calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap') + The defaults are False for real-world calendars + and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -921,7 +913,8 @@ cdef _year_zero_defaults(calendar): if calendar in ['standard','gregorian','julian']: return False elif calendar in ['proleptic_gregorian']: - return True # ISO 8601 year zero=1 BC + #return True # ISO 8601 year zero=1 BC + return False elif calendar in _idealized_calendars: return True else: @@ -961,10 +954,8 @@ If the has_year_zero kwarg is set to True, astronomical year numbering is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. -The defaults are set to conform with -CF conventions (False for 'julian', 'gregorian'/'standard', True -for 'proleptic_gregorian' (ISO 8601) and True for the idealized -calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap') +The defaults are False for real-world calendars +and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. @@ -1014,10 +1005,10 @@ The default format of the string produced by strftime is controlled by self.form has_year_zero = _year_zero_defaults(calendar) if not has_year_zero and calendar in _idealized_calendars: warnings.warn('has_year_zero kwarg ignored for idealized calendars (always True)') - if (calendar in ['julian','gregorian','standard'] and year <= 0) or\ - (calendar == 'proleptic_gregorian' and not has_year_zero and year < 1): - msg="this date/calendar/year zero convention is not supported by CF" - warnings.warn(msg,category=CFWarning) + #if (calendar in ['julian','gregorian','standard'] and year <= 0) or\ + # (calendar == 'proleptic_gregorian' and not has_year_zero and year < 1): + # msg="this date/calendar/year zero convention is not supported by CF" + # warnings.warn(msg,category=CFWarning) self.has_year_zero = has_year_zero if calendar == 'gregorian' or calendar == 'standard': # dates after 1582-10-15 can be converted to and compared to @@ -1286,9 +1277,9 @@ The default format of the string produced by strftime is controlled by self.form else: units = 'days since 0-1-1-12' # suppress warning about invalid CF date (year <= 0) - with warnings.catch_warnings(): - warnings.simplefilter("ignore",category=CFWarning) - jd = num2date(jday,units=units,calendar=calendar,has_year_zero=has_year_zero) + #with warnings.catch_warnings(): + # warnings.simplefilter("ignore",category=CFWarning) + jd = num2date(jday,units=units,calendar=calendar,has_year_zero=has_year_zero) return jd def toordinal(self,fractional=False): @@ -1763,10 +1754,8 @@ cdef _IntJulianDayFromDate(int year,int month,int day,calendar,skip_transition=F is used and the year zero exists. If set to False for real-world calendars, then historical year numbering is used and the year 1 is preceded by year -1 and no year zero exists. - The defaults are set to conform with - CF conventions (False for 'julian', 'gregorian'/'standard', True - for 'proleptic_gregorian' (ISO 8601) and True for the idealized - calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap') + The defaults are False for real-world calendars + and True for idealized calendars. The defaults can only be over-ridden for the real-world calendars, for the the idealized calendars the year zero always exists and the has_year_zero kwarg is ignored. diff --git a/test/test_cftime.py b/test/test_cftime.py index 0ed0c0db..ec09e8f1 100644 --- a/test/test_cftime.py +++ b/test/test_cftime.py @@ -1532,8 +1532,9 @@ def test_zero_year(date_type): # Proleptic Gregorian calendars by default. with warnings.catch_warnings(): warnings.simplefilter("ignore",category=cftime.CFWarning) - if date_type in [DatetimeNoLeap, DatetimeAllLeap, Datetime360Day, - DatetimeProlepticGregorian]: + #if date_type in [DatetimeNoLeap, DatetimeAllLeap, Datetime360Day, + # DatetimeProlepticGregorian]: + if date_type in [DatetimeNoLeap, DatetimeAllLeap, Datetime360Day]: date_type(0, 1, 1) else: with pytest.raises(ValueError):