Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.

improve documentation on fractional time seconds in timestamp/datetime #256

@ixcat

Description

@ixcat

more audit needed for full coverage across py/matlab; that said, it appears that at least for dj python, one needs to 'timestamp(N)' to get access to sub-second precision

see also: https://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html

no fractional seconds:

>>> @schema
... class TestStamp(dj.Manual):
...     definition = '''
...     ts_id: int
...     ---
...     ts_dat: datetime
...     '''
... 
>>> TestStamp().insert1((0, datetime.now()))
>>> TestStamp().fetch()
array([(0, datetime.datetime(2021, 2, 16, 10, 18, 57))],
      dtype=[('ts_id', '<i8'), ('ts_dat', 'O')])

with fractional seconds:

>>> @schema
... class TestOtherStamp(dj.Manual):
...     definition = '''
...     ts_id: int
...     ---
...     ts_dat: datetime(6)
...     '''
... 
>>> TestOtherStamp.insert1((0, datetime.now()))
>>> TestOtherStamp()
*ts_id    ts_dat        
+-------+ +------------+
0         2021-02-16 10:
 (Total: 1)

>>> TestOtherStamp().fetch()
array([(0, datetime.datetime(2021, 2, 16, 10, 30, 13, 223264))],
      dtype=[('ts_id', '<i8'), ('ts_dat', 'O')])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions