Skip to content

Commit bf376e8

Browse files
committed
require date/time units
1 parent e59822a commit bf376e8

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/spec/v2.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,20 @@ consists of 3 parts:
117117
``">"``: big-endian; ``"|"``: not-relevant)
118118
* One character code giving the basic type of the array (``"b"``: Boolean (integer
119119
type where all values are only True or False); ``"i"``: integer; ``"u"``: unsigned
120-
integer; ``"f"``: floating point; ``"c"``: complex floating point; ``"S"``: string
121-
(fixed-length sequence of char); ``"U"``: unicode (fixed-length sequence of
122-
Py_UNICODE); ``"V"``: other (void * – each item is a fixed-size chunk of memory))
120+
integer; ``"f"``: floating point; ``"c"``: complex floating point; ``"m"``: timedelta;
121+
``"M"``: datetime; ``"S"``: string (fixed-length sequence of char); ``"U"``: unicode
122+
(fixed-length sequence of Py_UNICODE); ``"V"``: other (void * – each item is a
123+
fixed-size chunk of memory))
123124
* An integer specifying the number of bytes the type uses.
124125

125126
The byte order MUST be specified. E.g., ``"<f8"``, ``">i4"``, ``"|b1"`` and
126127
``"|S12"`` are valid data type encodings.
127128

128-
Please note that NumPy's datetime64 ("M") and timedelta64 ("m") data types are **not**
129-
currently supported. Please store data using an appropriate physical data type instead,
130-
e.g., 64-bit integer.
129+
For datetime64 ("M") and timedelta64 ("m") data types, these MUST also include the
130+
units within square brackets. A list of valid units and their definitions are given in
131+
the `NumPy documentation on Datetimes and Timedeltas
132+
<https://docs.scipy.org/doc/numpy/reference/arrays.datetime.html#datetime-units>`_.
133+
For example, ``"<M8[ns]"`` specifies a datetime64 data type with nanosecond time units.
131134

132135
Structured data types (i.e., with multiple named fields) are encoded as a list
133136
of two-element lists, following `NumPy array protocol type descriptions (descr)
@@ -476,8 +479,8 @@ initially published to clarify ambiguities and add some missing information.
476479
decoded for arrays with a fixed-length byte string data type (:issue:`165`,
477480
:issue:`176`).
478481

479-
* The specification now clarifies that datetime64 and timedelta64 data types are not
480-
supported in this version (:issue:`85`).
482+
* The specification now clarifies that units must be specified for datetime64 and
483+
timedelta64 data types (:issue:`85`, :issue:`215`).
481484

482485
* The specification now clarifies that the '.zattrs' key does not have to be present for
483486
either arrays or groups, and if absent then custom attributes should be treated as

0 commit comments

Comments
 (0)