duration_iso_parser 0.2.1
duration_iso_parser: ^0.2.1 copied to clipboard
Package to parse a duration from ISO 8601 string (like P1M, PT15M, P2Y3W4DT5H).
0.2.1 #
- Added
CalendarDuration.isZerofor quick zero checks. - Added arithmetic operators (
+,-,*,~/) andcopyWithfor composing and scaling durations. - Made
CalendarDuration.resolve()andresolveToDuration()accept an optional baseDateTime(defaults to now). - Added
Comparable<CalendarDuration>support for sorting by approximate duration. - Made
CalendarDurationconstructorconstfor compile-time instantiation.
0.2.0 #
- Added
CalendarDurationclass to represent durations with separate calendar components (years, months, days) and time components (hours, minutes, seconds).CalendarDuration.resolve(DateTime? from)- resolves the calendar duration to a concreteDateTimeby adding it to the provided date (or current date if null).CalendarDuration.resolveToDuration(DateTime? from)- converts the calendar duration to a standardDurationbased on actual calendar math, accounting for varying month lengths, leap years, and DST.CalendarDuration.toApproximateDuration()- converts to an approximateDurationusing configurable fixed values (default: 30 days/month, 365 days/year), ignoring calendar variations and DST.
- Added
DurationParser.parseIsoString()method that parses ISO 8601 duration strings and returns aCalendarDurationwith preserved individual components (unlikeparse()which converts everything to days/seconds). - Deprecated
DurationParser.parse()method in favor ofparseIsoString(). The old method is still available but may be removed in future versions. - Updated SDK constraints to support Dart 3.x (
>=2.12.0 <4.0.0).
0.1.0+1 #
- Package description extended.
0.1.0 #
- Base implementation.