skillfed

cftime

Time-handling functionality from netcdf4-python

cftime v1.6.5 4.8M downloads/30d#2,215 on PyPI
Permissive license MIT AGING released

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 cftime

uv

uv add cftime

poetry

poetry add cftime

Installing 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

Development Status :: 5 - Production/StableOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering

Tags

calendar date to numeric time conversioncftime datetime handlingnetcdf time units parsingnon-standard calendar supportnum2date date2numastronomical year numberingclimate data time handling
climate-datatime-handlingnetcdf

More Scientific/Engineering packages