duration_iso_parser 0.2.1 copy "duration_iso_parser: ^0.2.1" to clipboard
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.isZero for quick zero checks.
  • Added arithmetic operators (+, -, *, ~/) and copyWith for composing and scaling durations.
  • Made CalendarDuration.resolve() and resolveToDuration() accept an optional base DateTime (defaults to now).
  • Added Comparable<CalendarDuration> support for sorting by approximate duration.
  • Made CalendarDuration constructor const for compile-time instantiation.

0.2.0 #

  • Added CalendarDuration class 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 concrete DateTime by adding it to the provided date (or current date if null).
    • CalendarDuration.resolveToDuration(DateTime? from) - converts the calendar duration to a standard Duration based on actual calendar math, accounting for varying month lengths, leap years, and DST.
    • CalendarDuration.toApproximateDuration() - converts to an approximate Duration using 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 a CalendarDuration with preserved individual components (unlike parse() which converts everything to days/seconds).
  • Deprecated DurationParser.parse() method in favor of parseIsoString(). 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.
2
likes
160
points
230
downloads

Publisher

verified publisherinnim.ru

Weekly Downloads

Package to parse a duration from ISO 8601 string (like P1M, PT15M, P2Y3W4DT5H).

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

in_date_utils

More

Packages that depend on duration_iso_parser