diff --git a/.appveyor.yml b/.appveyor.yml index cc8fc399..8aee0df5 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,14 +1,15 @@ environment: CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 matrix: - - TARGET_ARCH: x64 - NPY: 1.16 - PY: 3.6 - TARGET_ARCH: x64 - NPY: 1.16 + NPY: 1.17 PY: 3.7 + - TARGET_ARCH: x64 + NPY: 1.17 + PY: 3.8 + platform: - x64 @@ -24,18 +25,30 @@ install: throw "There are newer queued builds for this pull request, failing early." } # Add path, activate `conda` and update conda. - - cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat - - cmd: conda config --set always_yes yes --set changeps1 no --set show_channel_urls true - - cmd: conda update conda - - cmd: conda config --add channels conda-forge --force - - cmd: conda config --set channel_priority strict - - cmd: set PYTHONUNBUFFERED=1 - - cmd: conda install conda-build vs2008_express_vc_python_patch - - cmd: call setup_x64 - - - cmd: conda.exe create --name TEST python=%PY% numpy=%NPY% cython pip pytest pytest-cov - - cmd: conda info --all - - cmd: conda activate TEST + + - set URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" + - curl -fsS -o miniconda3.exe %URL% + - start /wait "" miniconda3.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%PYTHON% + - "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" + - call %PYTHON%\Scripts\activate + - conda config --set always_yes yes --set changeps1 no --set show_channel_urls true + - conda config --add channels conda-forge --force + - set PYTHONUNBUFFERED=1 + - conda install conda-build vs2008_express_vc_python_patch + - call setup_x64 + - conda create --name TEST python=%PY% numpy=%NPY% cython pip pytest pytest-cov + - conda activate TEST + # - cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat + # - cmd: conda config --set always_yes yes --set changeps1 no --set show_channel_urls true + # - cmd: conda update conda + # - cmd: conda config --add channels conda-forge --force + # - cmd: conda config --set channel_priority strict + # - cmd: set PYTHONUNBUFFERED=1 + # - cmd: conda install conda-build vs2008_express_vc_python_patch + # - cmd: call setup_x64 + # - cmd: conda.exe create --name TEST python=%PY% numpy=%NPY% cython pip pytest pytest-cov + # - cmd: conda info --all + # - cmd: conda activate TEST # Skip .NET project specific build phase. build: off diff --git a/Changelog b/Changelog index 90815976..12ffdc97 100644 --- a/Changelog +++ b/Changelog @@ -13,7 +13,9 @@ version 1.1.0 (not yet released) * If only_use_python_datetimes=True and only_use_cftime_datetimes=False, num2date only returns python datetime instances and raises an exception - if this is not possible. + if this is not possible. num2pydate convenience function added which just calls + num2date with only_use_python_datetimes=True and + only_use_cftime_datetimes=False. Remove positive times check, raise ValueError if python datetime tries to compute a date before MINYEAR (issue #134) diff --git a/cftime/_cftime.pyx b/cftime/_cftime.pyx index 04a07a9e..7c0cce73 100644 --- a/cftime/_cftime.pyx +++ b/cftime/_cftime.pyx @@ -247,9 +247,19 @@ def date2num(dates,units,calendar='standard'): return cdftime.date2num(dates) +def num2pydate(times,units,calendar='standard'): + """num2pydate(times,units,calendar='standard') + Always returns python datetime.datetime + objects and raise an error if this is not possible. + + Same as + num2date(times,units,calendar',only_use_cftime_datetimes=Falsee,only_use_python_datetimes=Truee) + """ + return num2date(times,units,calendar,only_use_cftime_datetimes=False,only_use_python_datetimes=True) + def num2date(times,units,calendar='standard',\ only_use_cftime_datetimes=True,only_use_python_datetimes=False): - """num2date(times,units,calendar='standard') + """num2date(times,units,calendar='standard',only_use_cftime_datetimes=True,only_use_python_datetimes=False) Return datetime objects given numeric time values. The units of the numeric time values are described by the `units` argument