Table of Contents

Class CfTimeUnits

Namespace
EncDotNet.S100.Datasets.NetCdf
Assembly
EncDotNet.S100.Datasets.NetCdf.dll

CF time units: a unit and a reference time, for example "hours since 2026-10-25 00:00:00" (CF Conventions §4.4, "Time Coordinate"). Converts a coordinate value to a UTC time.

public sealed class CfTimeUnits
Inheritance
CfTimeUnits
Inherited Members

Remarks

The units are seconds, minutes, hours or days, in the UDUNITS spellings (s, sec, min, h, hr, d, plural or singular). Months and years fail: their length varies, and CF advises against them. The reference time is YYYY-MM-DD, optionally followed by a time (hh, hh:mm or hh:mm:ss.sss, after a space or a T) and a time zone (Z, UTC or an offset such as +00:00 or -5); a time with no zone is UTC.

Only the standard (the default), gregorian and proleptic_gregorian calendars are supported; for the dates weather data uses they are the same. Any other calendar (noleap, 360_day, julian, …) fails with a CfConventionsException.

Properties

Epoch

The reference time, in UTC.

public DateTime Epoch { get; }

Property Value

DateTime

Text

The units as the file gives them.

public string Text { get; }

Property Value

string

Unit

The length of one unit, for example one hour.

public TimeSpan Unit { get; }

Property Value

TimeSpan

Methods

IsSupportedCalendar(string?)

Whether calendar is one this reader supports (empty means standard).

public static bool IsSupportedCalendar(string? calendar)

Parameters

calendar string

The calendar attribute.

Returns

bool

Parse(string, string?)

Parses CF time units.

public static CfTimeUnits Parse(string units, string? calendar = null)

Parameters

units string

The units attribute, for example "seconds since 1970-01-01 00:00:00".

calendar string

The calendar attribute, or null for the default (standard).

Returns

CfTimeUnits

The parsed units.

Exceptions

CfConventionsException

The units aren't "<unit> since <time>", the unit isn't seconds, minutes, hours or days, the time can't be read, or the calendar isn't supported.

ParseTime(string?)

Parses an ISO 8601-style time as CF and ACDD write it (2026-10-25 00:00:00, 2026-10-25T06:00:00Z, 2026-10-25), returning it in UTC, or null when it can't be read.

public static DateTime? ParseTime(string? text)

Parameters

text string

The time.

Returns

DateTime?

ToString()

Returns the units as the file gives them.

public override string ToString()

Returns

string

ToUtc(double)

Converts a coordinate value to a UTC time, to the nearest millisecond.

public DateTime ToUtc(double value)

Parameters

value double

The coordinate value, in Units since Epoch.

Returns

DateTime

The time, in UTC.

Exceptions

CfConventionsException

The value isn't finite, or the time is out of range.