cftime
Time-handling functionality from netcdf4-python
What it is and what it does
cftime is a time-handling library extracted from netcdf4-python that specializes in converting between calendar dates and numeric time values for scientific data. It handles non-standard calendars like 360-day calendars used in climate models and real-world calendars with support for astronomical year numbering, including year zero. The package is built around two core functions: num2date converts numeric time values into cftime.datetime objects, and date2num does the reverse. It depends only on numpy.
The library is commonly used in climate science, weather modeling, and geophysical data processing where time must be represented in non-Gregorian or extended calendars. It provides a cftime.datetime class that mimics Python's standard datetime but extends it with calendar awareness and methods like toordinal, fromordinal, and change_calendar for switching between calendar systems. The package has been maintained since its first release in 2018, with recent versions adding support for modern Python versions.
Use it for:
- Parse and convert NetCDF time coordinates in climate and weather datasets where non-standard calendars are used.
- Convert between 'days since' or 'seconds since' reference dates and human-readable dates for scientific data analysis.
- Handle astronomical year numbering and year-zero conventions in historical or extended-range climate simulations.
- Index and subset time-series data by converting date ranges to numeric time indices.
- Ensure consistent time representation across datasets with different calendar conventions in multi-model comparisons.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts between calendar dates and numeric time values for non-standard and real-world calendars, with support for astronomical year numbering and multiple calendar systems.
Yes. cftime is a stable, actively maintained library with no known vulnerabilities, permissive MIT licensing, and wide adoption in scientific computing (top 5000 PyPI packages). Install friction is moderate but well-mitigated by prebuilt wheels for all major platforms and Python versions. It is essential for anyone working with climate data, NetCDF files, or non-Gregorian calendars.
Install
cftime on PyPI
pip
pip install cftimeuv
uv add cftimepoetry
poetry add cftimeInstalling cftime
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.10–3.14 on macOS, Linux, Windows, and ARM platforms. Last release 305 days ago; maintenance status is aging but the package is marked Production/Stable.
License in practice
MIT license is permissive; no restrictions on commercial or private use, modification, or redistribution as long as the license and copyright notice are included.
Quickstart
pip install cftime
import cftime
import numpy
# Convert numeric time to datetime
times = cftime.num2date([0, 1, 2], units='days since reference', calendar='standard')
# Convert datetime back to numeric
nums = cftime.date2num(times, units='days since reference', calendar='standard')
Requires numpy; Python 3.10 or later.
Verify before relying
- Specific calendar systems supported beyond 'standard', 'gregorian', 'julian', 'proleptic_gregorian', '360_day', 'noleap', '365_day'.
- Whether performance improvements from earlier releases remain current in version 1.6.5.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | aging — 305 days since the last release |
| First released | |
| Downloads | 4,849,519/month — #2,215 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cftime-1.6.5-cp310-cp310-macosx_10_9_x86_64.whl; cftime-1.6.5-cp310-cp310-macosx_11_0_arm64.whl; cftime-1.6.5-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; cftime-1.6.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cftime-1.6.5-cp310-cp310-musllinux_1_2_x86_64.whl; cftime-1.6.5-cp310-cp310-win_amd64.whl; cftime-1.6.5-cp311-cp311-macosx_10_9_x86_64.whl; cftime-1.6.5-cp311-cp311-macosx_11_0_arm64.whl; cftime-1.6.5-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; cftime-1.6.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cftime-1.6.5-cp311-cp311-musllinux_1_2_x86_64.whl; cftime-1.6.5-cp311-cp311-win_amd64.whl; cftime-1.6.5-cp311-cp311-win_arm64.whl; cftime-1.6.5-cp312-cp312-macosx_10_13_x86_64.whl; cftime-1.6.5-cp312-cp312-macosx_11_0_arm64.whl; cftime-1.6.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; cftime-1.6.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cftime-1.6.5-cp312-cp312-musllinux_1_2_x86_64.whl; cftime-1.6.5-cp312-cp312-win_amd64.whl; cftime-1.6.5-cp312-cp312-win_arm64.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
nc-time-axisEnables matplotlib to plot data using cftime…
permissive · top 15,000 on PyPI
netCDF4netcdf4 provides a Python interface to read,…
permissive · top 5,000 on PyPI
pyCalverterConverts between different calendar systems,…
copyleft · top 15,000 on PyPI
jdcalConverts between Julian dates and Gregorian or…
permissive · top 5,000 on PyPI
datetime-quarterAdds quarter-based date handling to Python's…
permissive · top 15,000 on PyPI
convertdateConverts dates between the Gregorian calendar…
permissive · top 5,000 on PyPI
fiscalyearProvides fiscal year, quarter, month, and day…
permissive · top 15,000 on PyPI
x-wr-timezoneConverts ICS calendar files that use the…
copyleft · top 5,000 on PyPI
zhdateConverts between Chinese lunar calendar dates…
copyleft · top 15,000 on PyPI
neotimeNeotime provides temporal data classes…
permissive · top 15,000 on PyPI