Skip to content

v0.2.0

Compare
Choose a tag to compare
@Prodesire Prodesire released this 24 Oct 14:03
· 18 commits to main since this release

πŸŽ‰ Celebration! The second version of Morrow is released.

Features

  • For Morrow
    • ✨ Add fromordinal() which constructs a Morrow from a proleptic Gregorian ordinal.
    • ✨ The underlying implementation of strptime() has been replaced from Python to libc.
    • ✨ Add to_py() and from_py() to which can convert between Morrow and Python datetime.
  • For TimeDelta
    • ✨ Add many methods, such as total_seconds(), __add__(), __radd_(), __sub__(), __rsub__() and so on.
    • ✨ Add 3 new TimeDelta constants in morrow.timedelta: Min, Max, Resolution.
    • ✨ The __init__() method supports weeks, hours, minutes, milliseconds.

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