Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Apr 30, 2024
1 parent 04205a8 commit 34630f3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ round(DateTime,dt)
## Internal API

For CFTime 0.1.3 and before all date-times are encoded using internally milliseconds since a fixed time origin and stored as an `Int64` similar to julia's `Dates.DateTime`.
However, this approach does not allow to encode time with a sub-millisecond precision possible allowed by the CF convention and supported by e.g. [numpy](https://numpy.org/doc/1.25/reference/arrays.datetime.html#datetime-units). While `numpy` allows attosecond precision, it can only encode a time span of ±9.2 around the date 00:00:00 UTC on 1 January 1970. In CFTime the time origin and the number containing the duration and the time precision are now encoded as two additional type parameters.
However, this approach does not allow to encode time with a sub-millisecond precision allowed by the CF convention and supported by e.g. [numpy](https://numpy.org/doc/1.25/reference/arrays.datetime.html#datetime-units). While `numpy` allows attosecond precision, it can only encode a time span of ±9.2 around the date 00:00:00 UTC on 1 January 1970. In CFTime the time origin and the number containing the duration and the time precision are now encoded as two additional type parameters.

When wrapping CFTime data-time, it is recommended for performance reasons to make the containg structure also parametric, for example
When wrapping a CFTime date-time type, it is recommended for performance reasons to make the containg structure also parametric, for example

``` julia
struct MyStuct{T1,T2}
Expand All @@ -157,3 +157,11 @@ end
```

Future version of CFTime might add other type parameters.
Internally, `T1` corresponds to a `CFTime.Period{T,Tfactor,Texponent}` structure wrapping a number type T representing the duration expressed in seconds as:

```
duration * factor * 10^exponent
```

where `Tfactor` and `Texponent` are value types of `factor` and `exponent` respectively.
`T2` is a value type of the date origin tuple represented as `(year, month, day,...)`.

0 comments on commit 34630f3

Please sign in to comment.