formatISODuration.d.cts 777 B

1234567891011121314151617181920212223242526
  1. import type { Duration } from "./types.js";
  2. /**
  3. * @name formatISODuration
  4. * @category Common Helpers
  5. * @summary Format a duration object according as ISO 8601 duration string
  6. *
  7. * @description
  8. * Format a duration object according to the ISO 8601 duration standard (https://www.digi.com/resources/documentation/digidocs//90001488-13/reference/r_iso_8601_duration_format.htm)
  9. *
  10. * @param duration - The duration to format
  11. *
  12. * @returns The ISO 8601 duration string
  13. *
  14. * @example
  15. * // Format the given duration as ISO 8601 string
  16. * const result = formatISODuration({
  17. * years: 39,
  18. * months: 2,
  19. * days: 20,
  20. * hours: 7,
  21. * minutes: 5,
  22. * seconds: 0
  23. * })
  24. * //=> 'P39Y2M20DT0H0M0S'
  25. */
  26. export declare function formatISODuration(duration: Duration): string;