TimeDatetime

class astropy.time.TimeDatetime(val1, val2, scale, precision, in_subfmt, out_subfmt, from_jd=False)[source] [edit on github]

Bases: astropy.time.TimeUnique

Represent date as Python standard library datetime object

Example:

>>> from astropy.time import Time
>>> from datetime import datetime
>>> t = Time(datetime(2000, 1, 2, 12, 0, 0), scale='utc')
>>> t.iso
'2000-01-02 12:00:00.000'
>>> t.tt.datetime
datetime.datetime(2000, 1, 2, 12, 1, 4, 184000)

Attributes Summary

cache Return the cache associated with this instance.
jd2_filled
mask
masked
name
scale Time scale
value Convert to (potentially timezone-aware) datetime object.

Methods Summary

mask_if_needed(value)
set_jds(val1, val2) Convert datetime object contained in val1 to jd1, jd2
to_value([timezone, parent]) Convert to (potentially timezone-aware) datetime object.

Attributes Documentation

cache

Return the cache associated with this instance.

jd2_filled
mask
masked
name = 'datetime'
scale

Time scale

value

Convert to (potentially timezone-aware) datetime object.

If timezone is not None, return a timezone-aware datetime object.

Parameters:
timezone : {tzinfo, None} (optional)

If not None, return timezone-aware datetime.

Returns:
`~datetime.datetime`

If timezone is not None, output will be timezone-aware.

Methods Documentation

mask_if_needed(value) [edit on github]
set_jds(val1, val2)[source] [edit on github]

Convert datetime object contained in val1 to jd1, jd2

to_value(timezone=None, parent=None)[source] [edit on github]

Convert to (potentially timezone-aware) datetime object.

If timezone is not None, return a timezone-aware datetime object.

Parameters:
timezone : {tzinfo, None} (optional)

If not None, return timezone-aware datetime.

Returns:
`~datetime.datetime`

If timezone is not None, output will be timezone-aware.