| 1 | package Data::Transfigure::Type::DateTime::Duration 1.03; | ||
| 2 | use v5.26; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | # ABSTRACT: transfigures DateTime::Duration objects to ISO8601 format | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Data::Transfigure::Type::DateTime::Duration - transfigures DateTime::Duration | ||
| 10 | objects to ISO8601 format | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | C<Data::Transfigure::Type::DateTime::Duration> transfigures L<DateTime::Duration> | ||
| 15 | objects to L<ISO8601|https://en.wikipedia.org/wiki/ISO_8601#Durations> | ||
| 16 | (duration!) format. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | use Object::Pad; | ||
| 21 | |||
| 22 | use Data::Transfigure::Type; | ||
| 23 | class Data::Transfigure::Type::DateTime::Duration : isa(Data::Transfigure::Type) { | ||
| 24 | use DateTime::Format::Duration::ISO8601; | ||
| 25 | |||
| 26 | =head1 FIELDS | ||
| 27 | |||
| 28 | I<none> | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | sub BUILDARGS ($class) { | ||
| 33 | $class->SUPER::BUILDARGS( | ||
| 34 | type => q(DateTime::Duration), | ||
| 35 | handler => sub ($data) { | ||
| 36 | return DateTime::Format::Duration::ISO8601->format_duration($data); | ||
| 37 | } | ||
| 38 | ); | ||
| 39 | } | ||
| 40 | |||
| 41 | } | ||
| 42 | |||
| 43 | =pod | ||
| 44 | |||
| 45 | =head1 AUTHOR | ||
| 46 | |||
| 47 | Mark Tyrrell C<< <mark@tyrrminal.dev> >> | ||
| 48 | |||
| 49 | =head1 LICENSE | ||
| 50 | |||
| 51 | Copyright (c) 2024 Mark Tyrrell | ||
| 52 | |||
| 53 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 54 | of this software and associated documentation files (the "Software"), to deal | ||
| 55 | in the Software without restriction, including without limitation the rights | ||
| 56 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 57 | copies of the Software, and to permit persons to whom the Software is | ||
| 58 | furnished to do so, subject to the following conditions: | ||
| 59 | |||
| 60 | The above copyright notice and this permission notice shall be included in all | ||
| 61 | copies or substantial portions of the Software. | ||
| 62 | |||
| 63 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 64 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 65 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 66 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 67 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 68 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 69 | SOFTWARE. | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | 1; | ||
| 74 | |||
| 75 | __END__ |