DateTimeX-Easy-0.0910007554352232410226242 014313334443 14726 5ustar00jnapiorkowski000000000000README1006444352232410226242 64514313334443 15654 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091This archive contains the distribution DateTimeX-Easy, version 0.091: Parse a date/time string using the best method available This software is copyright (c) 2022 by Robert Krimen and others, see the git log. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.025. Changes1006444352232410226242 672114313334443 16310 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.0910.091 2022 September 23 - Fixed issues with broken metadata in previous release and some fixes to POD issues and documentation fixes. - I removed all the complex pod weaver and dzil metadata plugins since they seemed to be failing to build a correct distribution. I never use any of these plugins and can't get them to work. Given this is a distribution that sees very little release cycle I don't find it useful to make this two file distribution so complicated. 0.090: - Fixed test issues related to changes up the CPAN stream 0.089: - Remove DateTime::Format::DateManip from dependencies due to instability in that package and its dependencies. 0.088: - Remove DateTime::Format::DateParse from dependencies as fails lots of tests and not used (thanks ranguard) 0.087: - TODO'd some tests that were breaking because of time zone weirdness - The previous entry is an example of gooder english! 0.086 - Treat a 4 digit number as a year... Format::Flexible changed on how it interpreted them 0.085: - Integrated a patch of some broken tests (thanks DPAVLIN) 0.084: - Formal release of .083+ 0.083_2 Monday September 22 13:48:22 PDT 2008: - Added parsing and tests for http://rt.cpan.org/Public/Bug/Display.html?id=39373 - Made ::Flexible take precedence over ::DateParse (for tz handling) - Added some Date::Parse tests 0.083_1 Friday September 19 16:32:17 PDT 2008: - Import into github: git://github.com/robertkrimen/datetimex-easy.git - Now require ::ICal and ::DateManip - Dropped Build.PL 0.082 Wednesday November 21 00:12:42 PST 2007: - Added "ambiguous" flag to disallow ambiguous input 0.081 Sunday November 11 22:06:48 PST 2007: - Added "this " and "next " compatibility 0.080 Sunday November 11 18:15:39 PST 2007: - Added "... first/last of of functionality 0.076 Saturday November 10 22:27:39 PST 2007: - Fixed some failing tests due to inability to determine local timezone 0.075 Friday November 09 13:06:05 PST 2007: - Fixed "unable to parse" bug in ::Format::DateManip and ::Format::Flexible parsing 0.071 Friday November 09 11:48:25 PST 2007: - Fixed some typos pointed out by NKUITSE 0.070 Friday November 09 01:36:26 PST 2007: - Slight interface change and code cleanup - Can parse with ICal, DateParse, Flexible, Natural, and DateManip 0.060 Wednesday November 07 18:55:16 PST 2007: - Fixed a bug with ->convert and added tests - Enhanced ->convert to allow timezone specification 0.050 Wednesday November 07 11:48:08 PST 2007: - Cleaned up some documentation - Added covert flag for doing timezone conversion 0.042 Wednesday November 07 03:38:32 PST 2007: - Dependency update 0.040 Wednesday November 07 03:18:06 PST 2007: - Major changes to core processing. Dropped Date::Manip as its parsing is way to opaque. - Using DateTime::Format::Flexible and DateTime::Format::Natural 0.030 Tuesday November 06 22:15:52 PST 2007: - Namespace change to DateTimeX, whee! 0.021 Tuesday November 06 13:08:42 PST 2007: - Added convenience exports: parse parse_date, parse_datetime, date, datetime, new_date, new_datetime 0.020 Tuesday November 06 12:11:22 PST 2007: - Name change to Date::DateTime::Easy from DateTime::Easy at the request of Dave Rolsky 0.013 Tuesday November 06 02:51:05 PST 2007 - Minor documentation update 0.010 Tuesday November 06 01:13:49 PST 2007: - Initial version LICENSE1006444352232410226242 4377714313334443 16056 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091This software is copyright (c) 2022 by Robert Krimen and others, see the git log. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2022 by Robert Krimen and others, see the git log. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2022 by Robert Krimen and others, see the git log. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End cpanfile1006444352232410226242 200314313334443 16506 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091# Do not edit this file directly. To change prereqs, edit the `dist.ini` file. requires "Carp" => "0"; requires "Date::Parse" => "0"; requires "DateTime" => "0"; requires "DateTime::Format::DateManip" => "0"; requires "DateTime::Format::Flexible" => "0"; requires "DateTime::Format::ICal" => "0"; requires "DateTime::Format::Natural" => "0"; requires "DateTime::TimeZone" => "0"; requires "Exporter" => "0"; requires "Scalar::Util" => "0"; requires "Time::Zone" => "0"; requires "YAML" => "0"; requires "base" => "0"; requires "constant" => "0"; requires "strict" => "0"; requires "vars" => "0"; requires "warnings" => "0"; on 'test' => sub { requires "Test::More" => "0"; requires "Test::Most" => "0"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "0"; }; on 'develop' => sub { requires "Pod::Coverage::TrustPod" => "0"; requires "Test::EOF" => "0"; requires "Test::EOL" => "0"; requires "Test::More" => "0.88"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; }; dist.ini1006444352232410226242 105714313334443 16456 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091name = DateTimeX-Easy author = Robert Krimen copyright_holder = Robert Krimen and others, see the git log copyright_year = 2022 abstract = Parse a date/time string using the best method available version = 0.091 [@Basic] [MetaJSON] [MetaResources] homepage = https://github.com/jjn1056/datetimex-easy bugtracker.web = https://github.com/jjn1056/datetimex-easy/issues repository.web = https://github.com/jjn1056/datetimex-easy repository.url = https://github.com/jjn1056/datetimex-easy repository.type = git [Prereqs::FromCPANfile] META.yml1006444352232410226242 215514313334443 16263 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091--- abstract: 'Parse a date/time string using the best method available' author: - 'Robert Krimen ' build_requires: Test::More: '0' Test::Most: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.025, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: DateTimeX-Easy requires: Carp: '0' Date::Parse: '0' DateTime: '0' DateTime::Format::DateManip: '0' DateTime::Format::Flexible: '0' DateTime::Format::ICal: '0' DateTime::Format::Natural: '0' DateTime::TimeZone: '0' Exporter: '0' Scalar::Util: '0' Time::Zone: '0' YAML: '0' base: '0' constant: '0' strict: '0' vars: '0' warnings: '0' resources: bugtracker: https://github.com/jjn1056/datetimex-easy/issues homepage: https://github.com/jjn1056/datetimex-easy repository: https://github.com/jjn1056/datetimex-easy version: '0.091' x_generated_by_perl: v5.34.0 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' MANIFEST1006444352232410226242 43314313334443 16120 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.025. CONTRIBUTORS Changes LICENSE MANIFEST META.json META.yml Makefile.PL README cpanfile dist.ini lib/DateTimeX/Easy.pm lib/DateTimeX/Easy/DateParse.pm t/00-load.t t/01-basic.t t/02-tz-parse.t t/03-parse.t META.json1006444352232410226242 423114313334443 16430 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091{ "abstract" : "Parse a date/time string using the best method available", "author" : [ "Robert Krimen " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.025, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "DateTimeX-Easy", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::EOF" : "0", "Test::EOL" : "0", "Test::More" : "0.88", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Carp" : "0", "Date::Parse" : "0", "DateTime" : "0", "DateTime::Format::DateManip" : "0", "DateTime::Format::Flexible" : "0", "DateTime::Format::ICal" : "0", "DateTime::Format::Natural" : "0", "DateTime::TimeZone" : "0", "Exporter" : "0", "Scalar::Util" : "0", "Time::Zone" : "0", "YAML" : "0", "base" : "0", "constant" : "0", "strict" : "0", "vars" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Test::More" : "0", "Test::Most" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/jjn1056/datetimex-easy/issues" }, "homepage" : "https://github.com/jjn1056/datetimex-easy", "repository" : { "type" : "git", "url" : "https://github.com/jjn1056/datetimex-easy", "web" : "https://github.com/jjn1056/datetimex-easy" } }, "version" : "0.091", "x_generated_by_perl" : "v5.34.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.27", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } t0007554352232410226242 014313334443 15112 5ustar00jnapiorkowski000000000000DateTimeX-Easy-0.09100-load.t1006444352232410226242 23314313334443 16551 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/t#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'DateTimeX::Easy' ); } diag( "Testing DateTimeX::Easy $DateTimeX::Easy::VERSION, Perl $], $^X" ); Makefile.PL1006444352232410226242 345214313334443 16765 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.025. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Parse a date/time string using the best method available", "AUTHOR" => "Robert Krimen ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "DateTimeX-Easy", "LICENSE" => "perl", "NAME" => "DateTimeX::Easy", "PREREQ_PM" => { "Carp" => 0, "Date::Parse" => 0, "DateTime" => 0, "DateTime::Format::DateManip" => 0, "DateTime::Format::Flexible" => 0, "DateTime::Format::ICal" => 0, "DateTime::Format::Natural" => 0, "DateTime::TimeZone" => 0, "Exporter" => 0, "Scalar::Util" => 0, "Time::Zone" => 0, "YAML" => 0, "base" => 0, "constant" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Test::More" => 0, "Test::Most" => 0 }, "VERSION" => "0.091", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Date::Parse" => 0, "DateTime" => 0, "DateTime::Format::DateManip" => 0, "DateTime::Format::Flexible" => 0, "DateTime::Format::ICal" => 0, "DateTime::Format::Natural" => 0, "DateTime::TimeZone" => 0, "Exporter" => 0, "Scalar::Util" => 0, "Test::More" => 0, "Test::Most" => 0, "Time::Zone" => 0, "YAML" => 0, "base" => 0, "constant" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); CONTRIBUTORS1006444352232410226242 63014313334443 16646 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091 # DATETIMEX-EASY CONTRIBUTORS # This is the (likely incomplete) list of people who have helped make this distribution what it is, either via code contributions, patches, bug reports, help with troubleshooting, etc. A huge 'thank you' to all of them. * David Steinbrunner * John Napiorkowski * Leo Lapworth * RHPizzarro * Robert Krimen * Stephen Thirlwall * Wesley Schwengle 03-parse.t1006444352232410226242 153014313334443 16770 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/t#!perl use strict; use warnings; use Test::Most; plan qw/no_plan/; use DateTimeX::Easy; my $yyy = (localtime(time))[5] + 1900; for (split m/\n/, <<_END_) { 1994-06-16T07:29:35 @ -0600 | Wed, 16 Jun 94 07:29:35 CST 1994-10-13T10:13:13 @ -0700 | Thu, 13 Oct 94 10:13:13 -0700 1994-11-09T09:50:32 @ -0500 | Wed, 9 Nov 1994 09:50:32 -0500 (EST) $yyy-12-21T17:05:00 | 21 dec 17:05 $yyy-12-21T17:05:00 | 21-dec 17:05 $yyy-12-21T17:05:00 | 21/dec 17:05 1993-12-21T17:05:00 | 21/dec/93 17:05 1999-01-01T10:02:18 | 1999 10:02:18 "GMT" 1994-11-16T22:28:20 @ -0800 | 16 Nov 94 22:28:20 PST _END_ next if m/^\s*#/; my ($want, $from) = split m/\s*\|\s*/, $_, 2; my ($want_dt, $want_tz) = split m/\s*\@\s*/, $want, 2; $want_tz ||= "+0000"; my $dt = DateTimeX::Easy->new($from); is($dt, $want_dt); is($dt->strftime(q{%z}), $want_tz); } 01-basic.t1006444352232410226242 1475414313334443 16771 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/t#!perl use strict; use warnings; use Test::Most; plan qw/no_plan/; use DateTimeX::Easy qw/parse_datetime datetime/; { my $dt = DateTimeX::Easy->parse("Mon Mar 17, 2008 4:14 pm"); is($dt, "2008-03-17T16:14:00"); } my (%tz_ok); $tz_ok{ny} = eval { DateTime::TimeZone->new( name => 'America/New_York' ) && 1 }; $tz_ok{la} = eval { DateTime::TimeZone->new( name => 'America/Los_Angeles' ) && 1 }; my $local_time_zone; eval { $local_time_zone = DateTime::TimeZone->new(name => "local"); }; undef $local_time_zone if $@; my $dt; $dt = DateTimeX::Easy->new("2007/01/01"); is("$dt", "2007-01-01T00:00:00"); $dt = DateTimeX::Easy->parse("2007/01/01 23:22:01"); is("$dt", "2007-01-01T23:22:01"); $dt = DateTimeX::Easy::parse("2007/01/01 10:22:01 PM"); is("$dt", "2007-01-01T22:22:01"); $dt = DateTimeX::Easy::new("2007/02/01 10:22:01 PM", hour => 9); is("$dt", "2007-02-01T09:22:01"); $dt = parse_datetime("2007/01/04 10:22:01 PM", truncate => "year"); is("$dt", "2007-01-01T00:00:00"); $dt = DateTimeX::Easy->new(year => 2007, parse => "2007/01/01 23:22:01", timezone => "US/Eastern"); is("$dt", "2007-01-01T23:22:01"); is($dt->time_zone->name, "America/New_York"); $dt->set_time_zone("US/Pacific"); is("$dt", "2007-01-01T20:22:01"); $dt = datetime(parse => "2007/01/01 23:22:01", timezone => "US/Pacific"); is("$dt", "2007-01-01T23:22:01"); $dt = datetime(parse => "2007/01/01 23:22:01 US/Eastern", timezone => "US/Pacific"); is("$dt", "2007-01-01T20:22:01"); is($dt->time_zone->name, "America/Los_Angeles"); $dt = datetime(parse => "2007/01/01 23:22:01 -0500", timezone => "US/Pacific"); is("$dt", "2007-01-01T20:22:01"); is($dt->time_zone->name, "America/Los_Angeles"); $dt = datetime(parse => "2007/01/01 23:22:01 -0500"); is("$dt", "2007-01-01T23:22:01"); is($dt->time_zone->name, "-0500"); $dt->set_time_zone("US/Pacific"); is($dt->time_zone->name, "America/Los_Angeles"); is("$dt", "2007-01-01T20:22:01"); $dt = datetime(parse => "2007/01/01 23:22:01 PST8PDT", time_zone => "UTC"); is("$dt", "2007-01-02T07:22:01"); is($dt->time_zone->name, "UTC"); ok($dt = datetime("2007-10")); is("$dt", "2007-10-01T00:00:00"); is($dt->time_zone->name, "floating"); ok($dt = datetime("beginning day of month of 2007-10-02")); is("$dt", "2007-10-01T00:00:00"); is($dt->time_zone->name, "floating"); ok($dt = datetime("end day of month of 2007-10-02")); is("$dt", "2007-10-31T00:00:00"); is($dt->time_zone->name, "floating"); ok($dt = datetime("last month of year of 2007")); is("$dt", "2007-12-01T00:00:00"); is($dt->time_zone->name, "floating"); ok($dt = datetime("beginning day of 2007-10-02")); is("$dt", "2007-10-01T00:00:00"); is($dt->time_zone->name, "floating"); ok($dt = datetime("end day of 2007-10-02")); is("$dt", "2007-10-31T00:00:00"); is($dt->time_zone->name, "floating"); ok($dt = datetime("last month of 2007")); is("$dt", "2007-12-01T00:00:00"); is($dt->time_zone->name, "floating"); eval { datetime("last month of 2007", ambiguous => 0); }; ok($@); like($@, qr/Can't parse/); ok($dt = datetime("last month of year of 2007", ambiguous => 0)); is("$dt", "2007-12-01T00:00:00"); is($dt->time_zone->name, "floating"); TODO: { local $TODO = "The tests below do weird things in America/* ... change to use a specific, good time zone"; $dt = DateTimeX::Easy->new("today"); ok($dt); # Same thing: $dt = DateTimeX::Easy->new("now"); ok($dt); # Uses Date::Manip's coolness: $dt = DateTimeX::Easy->new("last monday"); ok($dt); # ... but in 1968: $dt = DateTimeX::Easy->new("last monday", year => 1968); ok($dt); # ... at the 100th nanosecond: $dt = DateTimeX::Easy->new("last monday", year => 1968, nanosecond => 100); ok($dt); # ... in US/Eastern: (This will NOT do a timezone conversion) $dt = DateTimeX::Easy->new("last monday", year => 1968, nanosecond => 100, timezone => "US/Eastern"); ok($dt); # This WILL do a proper timezone conversion: $dt = DateTimeX::Easy->new("last monday", year => 1968, nanosecond => 100, timezone => "US/Pacific"); $dt->set_time_zone("America/New_York"); ok($dt); } { my $eg; $eg = DateTimeX::Easy->parse("today"); # Will use a floating timezone ok($eg->time_zone->is_floating, "Today as floating"); $eg = DateTimeX::Easy->parse("2007-07-01 10:32:10"); # Will ALSO use a floating timezone ok($eg->time_zone->is_floating); is("$eg", "2007-07-01T10:32:10"); $eg = DateTimeX::Easy->parse("2007-07-01 10:32:10 PM US/Eastern"); # Will use US/Eastern as a timezone ok(!$eg->time_zone->is_floating); is($eg->time_zone->name, "America/New_York"); is("$eg", "2007-07-01T22:32:10"); $eg = DateTimeX::Easy->parse("2007-07-01 10:32:10 PM", time_zone => "floating"); # Will use the floating timezone ok($eg->time_zone->is_floating); is("$eg", "2007-07-01T22:32:10"); SKIP: { skip "Can't determine local timezone", 1 unless $local_time_zone; $eg = DateTimeX::Easy->parse("2007-07-01 10:32:10", time_zone_if_floating => "local"); # Will use the local timezone is($eg->time_zone->name, $local_time_zone->name); } $eg = DateTimeX::Easy->parse("2007-07-01 10:32:10 UTC", time_zone => "US/Pacific"); # Will convert from UTC to US/Pacific is($eg->time_zone->name, "America/Los_Angeles"); is("$eg", "2007-07-01T03:32:10"); my $dt = DateTime->new(year => 2007, month => 7, day => 1, hour => 22, minute => 32, second => 10)->set_time_zone("US/Eastern"); $eg = DateTimeX::Easy->parse($dt); # Will use US/Eastern as the timezone is($eg->time_zone->name, "America/New_York"); is("$eg", "2007-07-01T22:32:10"); $eg = DateTimeX::Easy->parse($dt, time_zone => "floating"); # Will use a floating timezone ok($eg->time_zone->is_floating); is("$eg", "2007-07-01T22:32:10"); # FIXED $eg = DateTimeX::Easy->parse($dt, time_zone => "PST8PDT", soft_time_zone_conversion => 1); # Will use "US/Pacific" as the timezone with *no* conversion is($eg->time_zone->name, "PST8PDT"); is("$eg", "2007-07-01T22:32:10"); $eg = DateTimeX::Easy->parse($dt)->set_time_zone("PST8PDT"); # Will use "US/Pacific" as the timezone WITH conversion is($eg->time_zone->name, "PST8PDT"); is("$eg", "2007-07-01T19:32:10"); $eg = DateTimeX::Easy->parse($dt, time_zone => "PST8PDT"); # Will ALSO use "US/Pacific" as the timezone WITH conversion is($eg->time_zone->name, "PST8PDT"); is("$eg", "2007-07-01T19:32:10"); $eg = DateTimeX::Easy->parse($dt, time_zone => "floating"); is($eg->time_zone->name, "floating"); is("$eg", "2007-07-01T22:32:10"); } 02-tz-parse.t1006444352232410226242 347314313334443 17432 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/t#!perl use strict; use warnings; use Test::Most; plan qw/no_plan/; use DateTimeX::Easy; my $dt; { $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 Eastern Daylight"); is($dt->time_zone->name, "America/New_York"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 Eastern Daylight Time"); is($dt->time_zone->name, "America/New_York"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 Eastern Daylight Time (GMT-05:00)"); is($dt->time_zone->name, "America/New_York"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 (GMT-05:00)"); is($dt->time_zone->name, "-0500"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 -05:00"); is($dt->time_zone->name, "-0500"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 -0500"); is($dt->time_zone->name, "-0500"); } { $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 Pacific Daylight"); is($dt->time_zone->name, "America/Los_Angeles"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 Pacific Daylight Time"); is($dt->time_zone->name, "America/Los_Angeles"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 Pacific Daylight Time (GMT-08:00)"); is($dt->time_zone->name, "America/Los_Angeles"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 (GMT-08:00)"); is($dt->time_zone->name, "-0800"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 -08:00"); is($dt->time_zone->name, "-0800"); $dt = DateTimeX::Easy->new("2008-09-16 13:23:57 -0800"); is($dt->time_zone->name, "-0800"); } __END__ "2008-09-16 13:23:57 Eastern Daylight Time (GMT-05:00)" perl -MDateTimeX::Easy -e 'print DateTimeX::Easy->new("2008-09-16 13:23:57 Eastern Daylight Time (GMT-05:00)");' which actually works as: "2008-09-16 13:23:57 (GMT-05:00)" perl -MDateTimeX::Easy -e 'print DateTimeX::Easy->new("2008-09-16 13:23:57 (GMT-05:00)");' DateTimeX0007554352232410226242 014313334443 17241 5ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/libEasy.pm1006444352232410226242 5102714313334443 20665 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/lib/DateTimeXpackage DateTimeX::Easy; use warnings; use strict; use constant DEBUG => 0; our $VERSION = '0.091'; =encoding UTF-8 =head1 NAME DateTimeX::Easy - Parse a date/time string using the best method available =head1 SYNOPSIS # Make DateTimeX object for "now": my $dt = DateTimeX::Easy->new("today"); # Same thing: my $dt = DateTimeX::Easy->new("now"); # Uses ::F::Natural's coolness (similar in capability to Date::Manip) my $dt = DateTimeX::Easy->new("last monday"); # ... but in 1969: my $dt = DateTimeX::Easy->new("last monday", year => 1969); # ... at the 100th nanosecond: my $dt = DateTimeX::Easy->new("last monday", year => 1969, nanosecond => 100); # ... in US/Eastern: (This will NOT do a timezone conversion) my $dt = DateTimeX::Easy->new("last monday", year => 1969, nanosecond => 100, timezone => "US/Eastern"); # This WILL do a proper timezone conversion: my $dt = DateTimeX::Easy->new("last monday", year => 1969, nanosecond => 100, timezone => "US/Pacific"); $dt->set_time_zone("US/Eastern"); # Custom DateTimeX ability: my $dt = DateTimeX::Easy->new("last second of last month"); $dt = DateTimeX::Easy->new("last second of first month of last year"); $dt = DateTimeX::Easy->new("last second of first month of 2000"); =head1 DESCRIPTION DateTimeX::Easy makes DateTime object creation quick and easy. It uses a variety of DateTime::Format packages to do the bulk of the parsing, with some custom tweaks to smooth out the rough edges (mainly concerning timezone detection and selection). =head1 PARSING Currently, DateTimeX::Easy will attempt to parse input in the following order: =over =item DateTime - Is the input a DateTime object? =item ICal - Was DT::F::ICal able to parse the input? =item DateParse - Was DT::F::DateParse able to parse the input? A caveat, I actually use a modified version of DateParse in order to avoid DateParse's default timezone selection. =item Natural - Was DT::F::Natural able to parse the input? Since this module barfs pretty loudly on strange input, we use a silent $SIG{__WARN__} to hide errors. =item Flexible - Was DT::F::Flexible able to parse the input? This step also looks at the string to see if there is any timezone information at the end. =item DateManip - Was DT::F::DateManip able to parse the input? DateManip isn't very nice with preserving the input timezone, but it's here as a last resort. =back =head1 "last second of first month of year of 2005" DateTimeX::Easy also provides additional parsing and transformation for input like: "first day of last month" "last day of last month" "last day of this month" "last day of next month" "last second of first month of last year" "ending day of month of 2007-10-02" "last second of first month of year of 2005" "last second of last month of year of 2005" "beginning day of month of 2007-10-02" "last month of year of 2007" It will look at each sequence of " of " and do ->add, ->subtract, and ->truncate operations on the parsed DateTime object Also, It's best to be as explicit as possible; the following will work: "last month of 2007" "last second of last month of 2005" "beginning day of 2007-10-02" This won't, though: "last day of 2007" You'll have to do this instead: "last day of year of 2007" The reason is that the date portion is opaque to the parser. It doesn't know whether it has "2007" or "2007-10" or "now" as the last input. To fix this, you can give a hint to the parser, like " of " (as in "year of 2007" above). WARNING: This feature is still somewhat new, so there may be bugs lurking about. Please forward failing tests/scenarios. =head1 METHODS =head2 DateTimeX::Easy->new( ... ) =head2 DateTimeX::Easy->parse( ... ) =head2 DateTimeX::Easy->parse_date( ... ) =head2 DateTimeX::Easy->parse_datetime( ... ) =head2 DateTimeX::Easy->date( ... ) =head2 DateTimeX::Easy->datetime( ... ) =head2 DateTimeX::Easy->new_date( ... ) =head2 DateTimeX::Easy->new_datetime( ... ) Parse the given date/time specification using ::F::Flexible or ::F::Natural and use the result to create a L object. Returns a L object. You can pass the following in: parse # The string or DateTime object to parse. year # A year to override the result of parsing month # A month to override the result of parsing day # A day to override the result of parsing hour # A hour to override the result of parsing minute # A minute to override the result of parsing second # A second to override the result of parsing truncate # A truncation parameter (e.g. year, day, month, week, etc.) time_zone # - Can be: timezone # * A timezone (e.g. US/Pacific, UTC, etc.) tz # * A DateTime special timezone (e.g. floating, local) # # - If neither "tz", "timezone", nor "time_zone" is set, then it'll use whatever is parsed. # - If no timezone is parsed, then the default is floating. # - If the given timezone is different from the parsed timezone, # then a time conversion will take place (unless "soft_time_zone_conversion" is set). # - Either "time_zone", "timezone", "tz" will work (in that order), with "time_zone" having highest precedence # - See below for examples! soft_time_zone_conversion # Set this flag to 1 if you don't want the time to change when a given timezone is # different from a parsed timezone. For example, "10:00 UTC" soft converted to # PST8PDT would be "10:00 PST8PDT". time_zone_if_floating # The value of this option should be a valid timezone. If this option is set, then a DateTime object # with a floating timezone has it's timezone set to the value. default_time_zone # Same as "time_zone_if_floating" ambiguous # Set this flag to 0 if you want to disallow ambiguous input like: # "last day of 2007" or "first minute of April" # This will require you to specify them as "last day of year of 2007" and "first minute of month of April" # instead. This flag is 1 (false) by default. ... and anything else that you want to pass to the DateTime->new constructor If C is specified, then DateTime->truncate will be run after object creation. Furthermore, you can simply pass the value for "parse" as the first positional argument of the DateTimeX::Easy call, e.g.: # This: DateTimeX::Easy->new("today", year => 2008, truncate => "hour"); # ... is the same as this: DateTimeX::Easy->new(parse => "today", year => 2008, truncate => "hour"); Timezone processing can be a little complicated. Here are some examples: DateTimeX::Easy->parse("today"); # Will use a floating timezone DateTimeX::Easy->parse("2007-07-01 10:32:10"); # Will ALSO use a floating timezone DateTimeX::Easy->parse("2007-07-01 10:32:10 US/Eastern"); # Will use US/Eastern as a timezone DateTimeX::Easy->parse("2007-07-01 10:32:10"); # Will use the floating timezone DateTimeX::Easy->parse("2007-07-01 10:32:10", time_zone_if_floating => "local"); # Will use the local timezone DateTimeX::Easy->parse("2007-07-01 10:32:10 UTC", time_zone => "US/Pacific"); # Will convert from UTC to US/Pacific my $dt = DateTime->now->set_time_zone("US/Eastern"); DateTimeX::Easy->parse($dt); # Will use US/Eastern as the timezone DateTimeX::Easy->parse($dt, time_zone => "floating"); # Will use a floating timezone DateTimeX::Easy->parse($dt, time_zone => "US/Pacific", soft_time_zone_conversion => 1); # Will use US/Pacific as the timezone with NO conversion # For example, "22:00 US/Eastern" will become "22:00 PST8PDT" DateTimeX::Easy->parse($dt)->set_time_zone("US/Pacific"); # Will use US/Pacific as the timezone WITH conversion # For example, "22:00 US/Eastern" will become "19:00 PST8PDT" DateTimeX::Easy->parse($dt, time_zone => "US/Pacific"); # Will ALSO use US/Pacific as the timezone WITH conversion =head1 EXPORT =head2 parse( ... ) =head2 parse_date( ... ) =head2 parse_datetime( ... ) =head2 date( ... ) =head2 datetime( ... ) =head2 new_date( ... ) =head2 new_datetime( ... ) Same syntax as above. See above for more information. =head1 MOTIVATION Although I really like using DateTime for date/time handling, I was often frustrated by its inability to parse even the simplest of date/time strings. There does exist a wide variety of DateTime::Format::* modules, but they all have different interfaces and different capabilities. Coming from a Date::Manip background, I wanted something that gave me the power of ParseDate while still returning a DateTime object. Most importantly, I wanted explicit control of the timezone setting at every step of the way. DateTimeX::Easy is the result. =head1 THANKS Dave Rolsky and crew for writing L =head1 SEE ALSO L L L L L L L =head1 AUTHOR Robert Krimen =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2022 by Robert Krimen and others, see the git log. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use base qw/Exporter/; our @EXPORT_OK = qw/datetime parse parse_datetime parse_date new_datetime new_date date/; use DateTime; use DateTime::Format::Natural; use DateTime::Format::Flexible; # use DateTime::Format::DateParse; # Unfortunately, not as useful to use because of that default "local" time zone business. use DateTimeX::Easy::DateParse; # Using this instead, hrm. use Scalar::Util qw/blessed/; use Carp; my $have_ICal; eval { require DateTime::Format::ICal; $have_ICal = 1; }; my $have_DateManip; eval { require DateTime::Format::DateManip; $have_DateManip = 1; }; my $natural_parser = DateTime::Format::Natural->new; my %_truncate_range = qw/ month year day month hour day minute hour second minute nanosecond second /; my %_delta_range = ( month => [qw/years months/], day => [qw/months days/], hour => [qw/days hours/], minute => [qw/hours minutes/], second => [qw/minutes seconds/], ); my %_first_or_last = qw/ first first last last begin first beginning first start first end last ending last /; my @_parser_order = qw/ Flexible DateParse Natural /; unshift @_parser_order, qw/ICal/ if $have_ICal; push @_parser_order, qw/DateManip/ if $have_DateManip; my %_parser_source = ( ICal => sub { return DateTime::Format::ICal->parse_datetime(shift); }, DateParse => sub { return DateTimeX::Easy::DateParse->parse_datetime(shift); }, Natural => sub { local $SIG{__WARN__} = sub { }; # Make sure ::Natural/Date::Calc stay quiet... don't really like this, oh well... my $dt = $natural_parser->parse_datetime(shift); return unless $natural_parser->success; return $dt; }, Flexible => sub { my $parse = shift; my $time_zone; # First, try to extract out any timezone information { ################################################## # 2008-09-16 13:23:57 Eastern Daylight (?:Time)? # ################################################## if ($parse =~ s/\s+(?:(Eastern|Central|Mountain|Pacific)\s+(?:Daylight|Standard)(?:\s+Time)?).*$// ) { $time_zone = "US/$1"; } ################################## # 2008-09-16 13:23:57 US/Eastern # ################################## elsif ($parse =~ s/\s+([A-Za-z][A-Za-z0-9\/\._]*)\s*$//) { # Look for a timezone-like string at the end of $parse $time_zone = $1; $parse = "$parse $time_zone" and undef $time_zone if $time_zone && $time_zone =~ m/^[ap]\.?m\.?$/i ; # Put back AM/PM if we accidentally slurped it out } ######################################################### # 2008-09-16 13:23:57 Eastern Daylight Time (GMT+05:00) # ######################################################### elsif ($parse =~ s/(?:\s+[A-Z]\w+)*\s+\(?(?:GMT|UTC)?([-+]\d{2}:\d{2})\)?\s*$// ) { $time_zone = $1; } # Flexible can't seem to parse (GMT+0:500) # elsif ($parse =~ s/(?:\s+[A-Z]\w+)*(\s+\(GMT[-+]\d{2}:\d{2}\)\s*)$//) { # $parse = "$parse $1"; # } ############################# # 2008-09-16 13:23:57 +0500 # ############################# elsif ($parse =~ s/\s+([-+]\d{3,})\s*$//) { $time_zone = $1; } } return unless my $dt = DateTime::Format::Flexible->build($parse); if ($time_zone) { $dt->set_time_zone("floating"); $dt->set_time_zone($time_zone); } return $dt; }, DateManip => sub { return DateTime::Format::DateManip->parse_datetime(shift); }, ); sub new { shift if $_[0] && $_[0] eq __PACKAGE__; my $parse; $parse = shift if @_ % 2; my %in = @_; $parse = delete $in{parse} if exists $in{parse}; my $truncate = delete $in{truncate}; my $soft_time_zone_conversion = delete $in{soft_time_zone_conversion}; my $time_zone_if_floating = delete $in{default_time_zone}; $time_zone_if_floating = delete $in{time_zone_if_floating} if exists $in{time_zone_if_floating}; my $parser_order = delete $in{parser_order}; my $parser_exclude = delete $in{parser_exclude}; my $ambiguous = 1; $ambiguous = delete $in{ambiguous} if exists $in{ambiguous}; my ($time_zone); $time_zone = delete $in{tz} if exists $in{tz}; $time_zone = delete $in{timezone} if exists $in{timezone}; $time_zone = delete $in{time_zone} if exists $in{time_zone} ; # "time_zone" takes precedence over "timezone" my @delta; my $original_parse = $parse; my $parse_dt; if ($parse) { if (blessed $parse && $parse->isa("DateTime")) { # We have a DateTime object as $parse $parse_dt = $parse; } else { if (1) { my $got_ambiguous; my ($last_delta); while ($parse =~ s/^\s*(start|first|last|(?:begin|end)(?:ning)?)\s+(year|month|day|hour|minute|second)\s+of\s+//i ) { my $first_or_last = $1; $first_or_last = $_first_or_last{ lc $first_or_last }; my $period = $2; $last_delta->{add} = ["${period}s" => 1] if $last_delta; push @delta, $last_delta = my $delta = { period => $period }; if ($first_or_last ne "first") { $delta->{last} = 1; $delta->{subtract} = ["${period}s" => 1]; } else { $delta->{first} = 1; } } my $last_parse = $parse; my $period; if ($parse =~ s/^\s*(start|this|next|first|last|(?:begin|end)(?:ning)?)\s+(year|month|day|hour|minute|second)(?:\s+of\s+)?// ) { $period = $2; $last_delta->{add} = ["${period}s" => 1] if $last_delta && $last_delta->{last}; push @delta, { truncate => $period }; $parse = $last_parse unless $parse; } elsif ($parse =~ s/^\s*(year|month|day|hour|minute|second)\s+of\s+//i) { $period = $1; $last_delta->{add} = ["${period}s" => 1] if $last_delta && $last_delta->{last}; push @delta, { truncate => $period }; } elsif (@delta) { $got_ambiguous = 1; $period = $last_delta->{period}; my $truncate = $_truncate_range{$period}; push @delta, my $delta = { truncate => $truncate }; my $delta_range = $_delta_range{$period}; if ($delta_range) { my ($add, $subtract) = @$delta_range; if ($last_delta->{last}) { $last_delta->{add} = ["${add}" => 1]; } } } croak "Can't parse \"$original_parse\" since it's too ambiguous" if $got_ambiguous && !$ambiguous; } my @parser_order = $parser_order ? ( ref $parser_order eq "ARRAY" ? @$parser_order : ($parser_order)) : @_parser_order; my (%parser_exclude); %parser_exclude = map { $_ => 1 } ( ref $parser_exclude eq "ARRAY" ? @$parser_exclude : ($parser_exclude)) if $parser_exclude; my %parser_source = %_parser_source; if (DEBUG) { warn "Parse $parse\n"; } # TODO Kinda hackish if ($parse =~ m/^[1-9]\d{3}$/) { # If it's a four digit year... yeah, arbitrary $parse_dt = DateTime->new(year => $parse); } while (!$parse_dt && @parser_order) { my $parser = shift @parser_order; next if $parser_exclude{$parser}; # warn "Try $parser:\n" if DEBUG; my $parser_code = $parser_source{$parser}; eval { $parse_dt = $parser_code->($parse); }; if (DEBUG) { if ($@) { warn "FAIL $parser: $@\n"; } elsif ($parse_dt) { warn "PASS $parser: $parse_dt\n"; } else { warn "FAIL $parser\n"; } } undef $parse_dt if $@; } } return unless $parse_dt; } my %DateTime; $DateTime{time_zone} = "floating"; if ($parse_dt) { $DateTime{$_} = $parse_dt->$_ for qw/year month day hour minute second nanosecond time_zone/; } @DateTime{ keys %in } = values %in; return unless my $dt = DateTime->new(%DateTime); if ($time_zone) { if ($soft_time_zone_conversion) { $dt->set_time_zone("floating"); } $dt->set_time_zone($time_zone); } elsif ($time_zone_if_floating && $dt->time_zone->is_floating) { $dt->set_time_zone($time_zone_if_floating); } if ($truncate) { $truncate = $truncate->[1] if ref $truncate eq "ARRAY"; $truncate = (values %$truncate)[0] if ref $truncate eq "HASH"; $dt->truncate(to => $truncate); } elsif (@delta) { if (DEBUG) { require YAML; warn "$original_parse => $parse => $dt"; } for my $delta (reverse @delta) { warn YAML::Dump($delta) if DEBUG; if ($delta->{truncate}) { $dt->truncate(to => $delta->{truncate}); } else { $dt->add(@{ $delta->{add} }) if $delta->{add}; $dt->subtract(@{ $delta->{subtract} }) if $delta->{subtract}; } } } return $dt; } *parse = \&new; *parse_date = \&new; *parse_datetime = \&new; *date = \&new; *datetime = \&new; *new_date = \&new; *new_datetime = \&new; 1; # End of DateTimeX::Easy __END__ Easy0007554352232410226242 014313334443 20142 5ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/lib/DateTimeXDateParse.pm1006444352232410226242 477314313334443 22523 0ustar00jnapiorkowski000000000000DateTimeX-Easy-0.091/lib/DateTimeX/Easypackage # DateTimeX::Easy::DateParse; # Yar, stolen directly. Just needed to change 'local' to 'floating' # Copyright (C) 2005-6 Joshua Hoblitt # # $Id: DateParse.pm 3517 2006-09-17 23:10:10Z jhoblitt $ # ABSTRACT: DateParse fork for datetimex::easy use strict; use vars qw($VERSION); $VERSION = '0.04'; # VERSION use DateTime; use DateTime::TimeZone; use Date::Parse qw( strptime ); use Time::Zone qw( tz_offset ); =over =item parse_datetime =back =cut sub parse_datetime { my ($class, $date, $zone) = @_; # str2time() calls strptime() internally so it's more efficent to use # strptime() directly. However, the extra validation done by using # DateTime->new() instad of DateTime->from_epoch() may make it into a net # loss. In the end, it turns out that strptime()'s offset information is # needed anyways. # CHANGED! Do not assume 'local' timezone by default! my @t = strptime( $date, "floating"); # my @t = strptime( $date, $zone ); return undef unless @t; my ($ss, $mm, $hh, $day, $month, $year, $offset) = @t; my %p; if ( $ss ) { my $fraction = $ss - int( $ss ); $p{ nanosecond } = $fraction * 1e9 if $fraction; $p{ second } = int $ss; } $p{ minute } = $mm if $mm; $p{ hour } = $hh if $hh; $p{ day } = $day if $day; $p{ month } = $month + 1 if $month; $p{ year } = $year ? $year + 1900 : DateTime->now->year; # unless there is an explict ZONE, Date::Parse seems to parse date only # formats, eg. "1995-01-24", as being in the 'local' timezone. unless ( defined $zone || defined $offset ) { # CHANGED! Do not assume 'local' timezone by default! return DateTime->new( %p, time_zone => 'floating', ); # time_zone => 'local', } if ( $zone ) { if ( DateTime::TimeZone->is_valid_name( $zone ) ) { return DateTime->new( %p, time_zone => $zone, ); } else { # attempt to convert Time::Zone tz's into an offset return DateTime->new( %p, time_zone => # not an Olson timezone, no DST info DateTime::TimeZone::offset_as_string( tz_offset( $zone ) ), ); } } return DateTime->new( %p, time_zone => # not an Olson timezone, no DST info DateTime::TimeZone::offset_as_string( $offset ), ); } 1; __END__