v0.2.0
π Celebration! The second version of Morrow is released.
Features
- For
Morrow- β¨ Add
fromordinal()which constructs aMorrowfrom a proleptic Gregorian ordinal. - β¨ The underlying implementation of
strptime()has been replaced from Python to libc. - β¨ Add
to_py()andfrom_py()to which can convert between Morrow and Python datetime.
- β¨ Add
- For
TimeDelta- β¨ Add many methods, such as
total_seconds(),__add__(),__radd_(),__sub__(),__rsub__()and so on. - β¨ Add 3 new
TimeDeltaconstants inmorrow.timedelta:Min,Max,Resolution. - β¨ The
__init__()method supports weeks, hours, minutes, milliseconds.
- β¨ Add many methods, such as
Internal
- π§ Run tests only on pull_request.
Example
from morrow import Morrow
# Return proleptic Gregorian ordinal for the year, month and day.
let m = Morrow(2023, 10, 1)
let ordinal = m.toordinal()
print(ordinal) # 738794
# Construct a Morrow from a proleptic Gregorian ordinal.
let m2 = Morrow.fromordinal(ordinal)
print(m2.__str__()) # 2023-10-01T00:00:00.000000
# Convert Morrow to python datetime
let now = Morrow.now()
let py_dt = now.to_py()
print(dt.isoformat()) # 2023-10-01T20:10:25.188957
# Convert python datetime to Morrow
let m_from_py = Morrow.from_py(py_dt)
print(m_from_py.__str__()) # 2023-10-01T20:10:25.188957