1MooseX::Types::DateTimeUXs(e3r)Contributed Perl DocumentMaotoisoenX::Types::DateTimeX(3)
2
3
4
6 MooseX::Types::DateTimeX - Extensions to
7 MooseX::Types::DateTime::ButMaintained
8
10 package MyApp::MyClass;
11
12 use MooseX::Types::DateTimeX qw( DateTime );
13
14 has created => (
15 isa => DateTime,
16 is => "rw",
17 coerce => 1,
18 );
19
20 my $instance = MyApp::MyClass->new(created=>'January 1, 1980');
21 print $instance->created->year; # is 1980
22
23 ## Coercions from the base type continue to work as normal.
24 my $instance = MyApp::MyClass->new(created=>{year=>2000,month=>1,day=>10});
25
26 Please see the test case for more example usage.
27
29 This module builds on MooseX::Types::DateTime to add additional custom
30 types and coercions. Since it builds on an existing type, all
31 coercions and constraints are inherited.
32
33 The package name is left as is for legacy reasons: this module is
34 really a Type with coercions for DateTimeX::Easy. DateTimeX is just a
35 namespace for non-core or less-official DateTime modules.
36
38 This module defines the following additional subtypes.
39
40 DateTime
41 Subtype of 'DateTime'. Adds an additional coercion from strings.
42
43 Uses DateTimeX::Easy to try and convert strings, like "yesterday" into
44 a valid DateTime object. Please note that due to ambiguity with how
45 different systems might localize their timezone, string parsing may not
46 always return the most expected value. IN general we try to localize
47 to UTC whenever possible. Feedback welcomed!
48
49 Duration
50 Subtype of 'DateTime::Duration' that coerces from a string. We use the
51 module Time::Duration::Parse to attempt this.
52
54 Firstly, this module uses DateTimeX::Easy which is way to more DWIM
55 than any sane person would desire. DateTimeX::Easy works by falling
56 back until something makes sense, this is variable. Furthermore, all
57 the modules that DateTimeX::Easy *can* use aren't required for "proper"
58 function of DateTimeX::Easy. What does this mean? Simple, your mileage
59 may vary in your coercions because DateTimeX::Easy is installation
60 specific.
61
63 • MooseX::Types::DateTime::ButMaintained Replacement for this module
64 -- coercions with less voodoo
65
66 • DateTimeX::Easy Backend of this module
67
69 John Napiorkowski <jjn1056 at yahoo.com>
70
71 Broken into a seperate package from MooseX::Types::DateTime by Evan
72 Carroll.
73
75 Copyright (c) 2008 John Napiorkowski.
76
77 This program is free software; you can redistribute
78 it and/or modify it under the same terms as Perl itself.
79
80
81
82perl v5.34.0 2022-01-21 MooseX::Types::DateTimeX(3)