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