Date-Pregnancy-0.06000755000765000024 012660554236 14167 5ustar00jonasbnstaff000000000000README100644000765000024 52712660554236 15114 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06 This archive contains the distribution Date-Pregnancy, version 0.06: calculate birthdate and week numbers for a pregnancy This software is Copyright (c) 2016 by Jonas B. Nielsen. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) This README file was generated by Dist::Zilla::Plugin::Readme v5.038. Changes100644000765000024 502412660554236 15544 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06Changes file for Date-Pregnancy 0.06 2016-02-16 Maintenance release, update not required - Spelling corrections from Nick Morrott [RT:112068] 0.05 2015-08-18 Maintenance release, update not required - License upgraded from artistic license 1.0 to artistic license 2.0 - Migrated from Module::Build to Dist::Zilla 0.04 2014-0816 Maintenance release, update not required - Added use of warnings - Added specification of required Perl version (5.8.0) 0.03 2006-08-18 Bug fix release, update required - Fixed some problem with calculations of both week numbers and month numbers I was making it uncessary complex (and buggy) - Added MANIFEST.SKIP (default from Module::Build, neat) - Fixed a bug in _countback method (also fixed a bug in a test relating to this here bug) - Cleaned Build.PL for files no longer in use - Removed obsolete tests (these can be handled by Module::Build): t/pod.t t/pod-coverage.t - Added new unit-test t/warnings.t added tests for getting full coverage - Updated INSTALL - Changed to Module::Build instead of ExtUtils::MakeMaker 0.02 2005-07-10 Bug fix release, update required - Changed use of constant module, the syntax use was of a newer version and as such not necessary, this fixes a bug, which appears with the constants module distributed with Perl 5.6. (and prior). This addresses test report: 166196 FAIL 5.6.1 on MSWin32 4.0 0.01 2004-10-13, Bug fix release, update required - Due to package name change from: DateTime::Pregnancy to Date::Pregnancy Also the version number has been reset from 0.02 to 0.01 - Added more tests to validate count back method, hence addition of year should be conditional - Fixed bug in countback method, a year should be added when the first day of the last period happens before april - Added tests to locate error reported by LTHEGLER - Fixed Makefile.PL - Renamed subdir in lib - Renaming module to Date::Pregnancy 0.01 2004-10-10 Initial release - Released under name: DateTime::Pregnancy - Added date parameter to calculcate week - Added several tests - Added use of clone (now things work as expected) - Added POD - Added Villads test - Added some simple error handling - Added calculate_month - Added BUGS file - Added MANIFEST file - Menstruation changed to period - Changed serious spelling error lenght to length - Separated calculation method into 3 separate parts, implementing: - The 40 weeks method - The count_back method - The 266 days method - Added t/methods.t - Added use of POSIX, we use floor in the 266days method LICENSE100644000765000024 2152512660554236 15302 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06This software is Copyright (c) 2016 by Jonas B. Nielsen. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) The Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. dist.ini100644000765000024 210712660554236 15714 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06name = Date-Pregnancy author = Jonas B. Nielsen license = Artistic_2_0 copyright_holder = Jonas B. Nielsen [@Basic] [VersionFromModule] [GitHub::Meta] issues = 1 ; enabling issues on github [ExtraTests] [Test::Perl::Critic] critic_config = t/perlcriticrc [PodCoverageTests] [PodSyntaxTests] [Test::Kwalitee] [Test::Compile] fail_on_warning = none [Test::CPAN::Changes] [ModuleBuild] mb_version = 0.30 [MetaJSON] ; Ref: http://blogs.perl.org/users/ovid/2014/03/a-simple-distini-for-distzilla.html [ ReadmeAnyFromPod / MarkdownInRoot ] filename = README.mkdn [MetaProvides::Package] inherit_version = 0 ;optional flag inherit_missing = 0 ;optional flag meta_noindex = 1 ;optional flag [Prereqs] DateTime = 0 Clone = 0 Carp = 0 Exporter = 0 POSIX = 0 perl = 5.008 ; 5.8.0 [Prereqs / TestRequires] Test::More = 0.88 Test::Kwalitee = 1.21 ; from Dist::Zilla Pod::Coverage::TrustPod = 0 ; from Dist::Zilla Test::Pod = 1.41 ; from Dist::Zilla Test::Pod::Coverage = 1.08 ; from Dist::Zilla META.yml100644000765000024 170112660554236 15520 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06--- abstract: 'calculate birthdate and week numbers for a pregnancy' author: - 'Jonas B. Nielsen ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Module::Build: '0.30' Pod::Coverage::TrustPod: '0' Test::Kwalitee: '1.21' Test::More: '0.88' Test::Pod: '1.41' Test::Pod::Coverage: '1.08' configure_requires: ExtUtils::MakeMaker: '0' Module::Build: '0.30' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.038, CPAN::Meta::Converter version 2.150005' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Date-Pregnancy provides: Date::Pregnancy: file: lib/Date/Pregnancy.pm version: '0.06' requires: Carp: '0' Clone: '0' DateTime: '0' Exporter: '0' POSIX: '0' perl: '5.008' resources: homepage: http://search.cpan.org/dist/Date-Pregnancy/ repository: git://github.com/jonasbn/Date-Pregnancy.git version: '0.06' MANIFEST100644000765000024 65112660554236 15363 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.038. Build.PL Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Date/Pregnancy.pm t/00-compile.t t/Villads.t t/author-critic.t t/calculate_birthday.t t/calculate_month.t t/calculate_week.t t/methods.t t/perlcriticrc t/release-cpan-changes.t t/release-kwalitee.t t/release-pod-coverage.t t/release-pod-syntax.t t/warnings.t Build.PL100644000765000024 302012660554236 15537 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06 # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.038. use strict; use warnings; use Module::Build 0.30; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.30" }, "configure_requires" => { "ExtUtils::MakeMaker" => 0, "Module::Build" => "0.30" }, "dist_abstract" => "calculate birthdate and week numbers for a pregnancy", "dist_author" => [ "Jonas B. Nielsen " ], "dist_name" => "Date-Pregnancy", "dist_version" => "0.06", "license" => "artistic_2", "module_name" => "Date::Pregnancy", "recursive_test_files" => 1, "requires" => { "Carp" => 0, "Clone" => 0, "DateTime" => 0, "Exporter" => 0, "POSIX" => 0, "perl" => "5.008" }, "test_requires" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Pod::Coverage::TrustPod" => 0, "Test::Kwalitee" => "1.21", "Test::More" => "0.88", "Test::Pod" => "1.41", "Test::Pod::Coverage" => "1.08" } ); my %fallback_build_requires = ( "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Module::Build" => "0.30", "Pod::Coverage::TrustPod" => 0, "Test::Kwalitee" => "1.21", "Test::More" => "0.88", "Test::Pod" => "1.41", "Test::Pod::Coverage" => "1.08" ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; META.json100644000765000024 374012660554236 15675 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06{ "abstract" : "calculate birthdate and week numbers for a pregnancy", "author" : [ "Jonas B. Nielsen " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.038, CPAN::Meta::Converter version 2.150005", "license" : [ "artistic_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Date-Pregnancy", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.30" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "Module::Build" : "0.30" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Changes" : "0.19", "Test::Kwalitee" : "1.21", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Carp" : "0", "Clone" : "0", "DateTime" : "0", "Exporter" : "0", "POSIX" : "0", "perl" : "5.008" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Pod::Coverage::TrustPod" : "0", "Test::Kwalitee" : "1.21", "Test::More" : "0.88", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } } }, "provides" : { "Date::Pregnancy" : { "file" : "lib/Date/Pregnancy.pm", "version" : "0.06" } }, "release_status" : "stable", "resources" : { "homepage" : "http://search.cpan.org/dist/Date-Pregnancy/", "repository" : { "type" : "git", "url" : "git://github.com/jonasbn/Date-Pregnancy.git", "web" : "https://github.com/jonasbn/Date-Pregnancy" } }, "version" : "0.06" } t000755000765000024 012660554236 14353 5ustar00jonasbnstaff000000000000Date-Pregnancy-0.06methods.t100644000765000024 261112660554236 16343 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t# $Id$ use strict; use Test::More tests => 17; use DateTime; #test 1 use_ok( "Date::Pregnancy", qw( calculate_birthday _countback _266days _40weeks )); my $dt = DateTime->new( year => 2004, month => 3, day => 19, ); #test 2-3 my $birthday; ok($birthday = _40weeks($dt)); isa_ok($birthday, "DateTime"); $birthday = undef; #test 4-5 ok($birthday = _266days($dt, 28)); isa_ok($birthday, "DateTime"); $birthday = undef; #test 6-7 ok($birthday = _countback($dt)); isa_ok($birthday, "DateTime"); $birthday = undef; #test 8 eval { calculate_birthday( first_day_of_last_period => $dt, method => 'nonexisting') }; like($@, qr/Unknown method: nonexisting/); $dt = DateTime->new( year => 2004, month => 12, day => 24, ); $birthday = calculate_birthday( first_day_of_last_period => $dt, method => 'countback' ); #test 9-11 is($birthday->day, 30); is($birthday->month, 9); is($birthday->year, 2005); $dt = DateTime->new( year => 2006, month => 7, day => 1, ); $birthday = calculate_birthday( first_day_of_last_period => $dt, method => 'countback' ); #test 12-14 is($birthday->day, 8); is($birthday->month, 4); is($birthday->year, 2007); $dt = DateTime->new( year => 2007, month => 1, day => 1, ); $birthday = calculate_birthday( first_day_of_last_period => $dt, method => 'countback' ); #test 15-17 is($birthday->day, 8); is($birthday->month, 10); is($birthday->year, 2007);Villads.t100644000765000024 235612660554236 16304 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t# $Id$ use strict; use Test::More tests => 10; use DateTime; use_ok( "Date::Pregnancy", qw(calculate_birthday calculate_week calculate_month)); my $dt = DateTime->new( year => 2004, month => 3, day => 19, ); my $villads_birthday_266days = calculate_birthday( first_day_of_last_period => $dt ); is($villads_birthday_266days->day, 24); is($villads_birthday_266days->month, 12); is($villads_birthday_266days->year, 2004); my $villads_birthday_40weeks = calculate_birthday( first_day_of_last_period => $dt, method => '40weeks' ); is($villads_birthday_40weeks->day, 24); is($villads_birthday_40weeks->month, 12); is($villads_birthday_40weeks->year, 2004); my $villads_birthday_countback = calculate_birthday( first_day_of_last_period => $dt, method => 'countback' ); is($villads_birthday_countback->day, 26); is($villads_birthday_countback->month, 12); is($villads_birthday_countback->year, 2004); print STDERR "\nVillads' birthday is calculated to be:\n"; print STDERR $villads_birthday_266days->dmy." according to the 266 days method\n"; print STDERR $villads_birthday_40weeks->dmy." according to the 40 weeks method\n"; print STDERR $villads_birthday_countback->dmy." according to the count back method\n"; Makefile.PL100644000765000024 326712660554236 16232 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.038. use strict; use warnings; use 5.008; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "calculate birthdate and week numbers for a pregnancy", "AUTHOR" => "Jonas B. Nielsen ", "BUILD_REQUIRES" => { "Module::Build" => "0.30" }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "Module::Build" => "0.30" }, "DISTNAME" => "Date-Pregnancy", "LICENSE" => "artistic_2", "MIN_PERL_VERSION" => "5.008", "NAME" => "Date::Pregnancy", "PREREQ_PM" => { "Carp" => 0, "Clone" => 0, "DateTime" => 0, "Exporter" => 0, "POSIX" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Pod::Coverage::TrustPod" => 0, "Test::Kwalitee" => "1.21", "Test::More" => "0.88", "Test::Pod" => "1.41", "Test::Pod::Coverage" => "1.08" }, "VERSION" => "0.06", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Clone" => 0, "DateTime" => 0, "Exporter" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Module::Build" => "0.30", "POSIX" => 0, "Pod::Coverage::TrustPod" => 0, "Test::Kwalitee" => "1.21", "Test::More" => "0.88", "Test::Pod" => "1.41", "Test::Pod::Coverage" => "1.08" ); 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); warnings.t100644000765000024 123212660554236 16526 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t# $Id: warnings.t 1596 2005-10-14 05:02:32Z jonasbn $ use strict; use Test::More tests => 10; use DateTime; #test 1 use_ok( "Date::Pregnancy", qw( calculate_birthday calculate_week calculate_month _countback _266days _40weeks )); #test 2 is(_40weeks(), undef); #test 3 is(_266days(), undef); my $dt = DateTime->new( year => 2004, month => 3, day => 19, ); #test 4 is(_266days($dt), undef); #test 5 is(_countback(), undef); #test 6 is(calculate_birthday(), undef); #test 7 is(calculate_week(), undef); #test 8 is(calculate_week(date => $dt), undef); #test 9 is(calculate_month(), undef); #test 10 is(calculate_month(birtday => $dt), undef); perlcriticrc100644000765000024 12512660554236 17101 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t[-Subroutines::ProhibitExplicitReturnUndef] [-BuiltinFunctions::ProhibitStringyEval]00-compile.t100644000765000024 177712660554236 16561 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.053 use Test::More; plan tests => 1; my @module_files = ( 'Date/Pregnancy.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } # no warning checks; author-critic.t100644000765000024 67012660554236 17440 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "t/perlcriticrc" ) if -e "t/perlcriticrc"; all_critic_ok(); calculate_week.t100644000765000024 172212660554236 17652 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t# $Id$ use strict; use Test::More tests => 58; use DateTime; #test 1 use_ok( "Date::Pregnancy", qw(calculate_week)); my $dt = DateTime->new( year => 2004, month => 3, day => 19, ); #test 2 is($dt->week_number, 12); my $week; #test 3 ok($week = calculate_week( first_day_of_last_period => $dt, )); #test 4 like($week, qr/\d+/); my $dt2 = DateTime->new( year => 2004, month => 10, day => 9, ); #test 5 ok($week = calculate_week( first_day_of_last_period => $dt, date => $dt2, )); #test 6 is($week, 29); $dt2 = DateTime->new( year => 2004, month => 12, day => 24, ); #test 7 ok($week = calculate_week( first_day_of_last_period => $dt, date => $dt2, )); #test 8 is($week, 40); #test 9 is(calculate_week(), undef); #Testing week numbers my $weeks_dt = $dt->clone(); for(my $i = 1; $i < 50; $i++) { $weeks_dt->add(days => 7); is(calculate_week(first_day_of_last_period => $dt, date => $weeks_dt), $i); }calculate_month.t100644000765000024 140412660554236 20041 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t# $Id: calculate_month.t 1630 2006-08-18 20:47:12Z jonasbn $ use strict; use Test::More tests => 15; #test 1 use_ok( "Date::Pregnancy", qw(calculate_month)); my $dt = DateTime->new( year => 2004, month => 3, day => 19, ); my $month; #test 2 ok($month = calculate_month( first_day_of_last_period => $dt, )); #test 3 like($month, qr/\d+/); my $dt2 = DateTime->new( year => 2004, month => 12, day => 23, ); #test 4 ok($month = calculate_month( first_day_of_last_period => $dt, date => $dt2, )); #test 5 is($month, 9); #test 6 is(calculate_month(), undef); my $months_dt = $dt->clone(); for(my $i = 1; $i < 10; $i++) { $months_dt->add(months => 1); is(calculate_month(first_day_of_last_period => $dt, date => $months_dt), $i); }release-kwalitee.t100644000765000024 53312660554236 20104 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.11 use strict; use warnings; use Test::More 0.88; use Test::Kwalitee 1.21 'kwalitee_ok'; kwalitee_ok(); done_testing; Date000755000765000024 012660554236 15533 5ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/libPregnancy.pm100644000765000024 3007212660554236 20201 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/lib/Datepackage Date::Pregnancy; use strict; use warnings; use DateTime; use Carp; use Clone qw(clone); use POSIX qw(ceil); use vars qw($VERSION @ISA @EXPORT_OK); require Exporter; use POSIX qw(floor); use 5.008; #5.8.0 $VERSION = '0.06'; @ISA = qw(Exporter); @EXPORT_OK = qw( calculate_birthday calculate_week calculate_month _countback _266days _40weeks ); use constant AVG_CYCLE => 28; use constant DAY => ( 60 * 60 * 24 ); sub _40weeks { my $dt = shift || carp "first_day_of_last_period parameter is mandatory"; return undef unless ( ref $dt ); my $birthday = clone($dt); $birthday->add( weeks => 40 ); return $birthday; } sub _266days { my ( $dt, $period_cycle_length ) = @_; unless ( ref $dt ) { carp "first_day_of_last_period parameter is mandatory"; return undef; } if ( !$period_cycle_length ) { carp "period_cycle_length parameter is mandatory"; return undef; } my $birthday = clone($dt); if ( $period_cycle_length > 28 ) { $birthday->add( seconds => ( DAY * floor( $period_cycle_length * 0.85 * ( 2 / 3 ) ) ) ); } elsif ( $period_cycle_length < 29 ) { $birthday->add( seconds => ( DAY * ( $period_cycle_length / 2 ) ) ); } $birthday->add( days => 266 ); return $birthday; } sub _countback { my $dt = shift || carp "first_day_of_last_period parameter is mandatory"; return undef unless ( ref $dt ); my $birthday = clone($dt); $birthday->add( days => 7 ); $birthday->subtract( months => 3 ); $birthday->add( years => 1 ); #if ($dt->month < 3) { #} return $birthday; } sub calculate_birthday { my %params = @_; my $method = $params{'method'} || '266days'; my $period_cycle_length = $params{'period_cycle_length'} || AVG_CYCLE; my $first_day_of_last_period = $params{'first_day_of_last_period'} || carp "first_day_of_last_period parameter is mandatory"; return undef unless ( ref $first_day_of_last_period ); my $calculation = "_$method"; my @methods = qw(_countback _266days _40weeks); unless ( grep {/$method/} @methods ) { croak "Unknown method: $params{'method'}"; } $calculation .= '($first_day_of_last_period'; if ( $method eq '266days' ) { $calculation .= ', $period_cycle_length'; } $calculation .= ');'; my $birthday = eval("$calculation"); croak $@ if $@; return $birthday; } sub calculate_week { my %params = @_; my $period_cycle_length = $params{'period_cycle_length'} || AVG_CYCLE; my $now = $params{'date'} || DateTime->now; $now->set_time_zone('UTC'); my $method = $params{'method'} || '40weeks'; my $birthday; if ( $params{'birthday'} ) { $birthday = $params{'birthday'}; } else { $birthday = calculate_birthday( first_day_of_last_period => $params{'first_day_of_last_period'}, period_cycle_length => $period_cycle_length, method => $method, ); return undef unless ( ref $birthday ); } $birthday->set_time_zone('UTC'); $birthday->subtract( months => 9 ); my $duration = $birthday->delta_days($now); return ( $duration->weeks + 1 ); } sub calculate_month { my %params = @_; my $period_cycle_length = $params{'period_cycle_length'} || AVG_CYCLE; my $now = $params{'date'} || DateTime->now; $now->set_time_zone('UTC'); my $method = $params{'method'} || '40weeks'; my $birthday; if ( $params{'birthday'} ) { $birthday = $params{'birthday'}; } else { $birthday = calculate_birthday( first_day_of_last_period => $params{'first_day_of_last_period'}, period_cycle_length => $period_cycle_length, method => $method, ); return undef unless ( ref $birthday ); } $birthday->set_time_zone('UTC'); $birthday->subtract( months => 9 ); my $duration = $birthday->delta_md($now); return ( $duration->months + 1 ); } 1; __END__ =pod =begin markdown [![CPAN version](https://badge.fury.io/pl/Date-Pregnancy.svg)](http://badge.fury.io/pl/Date-Pregnancy) [![Build Status](https://travis-ci.org/jonasbn/Date-Pregnancy.svg?branch=master)](https://travis-ci.org/jonasbn/Date-Pregnancy) [![Coverage Status](https://coveralls.io/repos/jonasbn/Date-Pregnancy/badge.png)](https://coveralls.io/r/jonasbn/Date-Pregnancy) =end markdown =head1 NAME Date::Pregnancy - calculate birthdate and week numbers for a pregnancy =head1 VERSION This documentation describes version 0.05 =head1 SYNOPSIS use Date::Pregnancy qw(calculate_birthday); my $dt = DateTime->new( year => 2004, month => 3, day => 19, ); $birthday = calculate_birthday(first_day_of_last_period => $dt); $birthday = calculate_birthday( first_day_of_last_period => $dt, period_cycle_length => 28, ); use Date::Pregnancy qw(calculate_week); $week = calculate_week(first_day_of_last_period => $dt); $dt2 = DateTime->new( year => 2004, month => 12, day => 24, ); $week = calculate_week( first_day_of_last_period => $dt, date => $dt2, ); $week = calculate_week( first_day_of_last_period => $dt, method => '40weeks', ); $week = calculate_week(birthday => $birthday); use Date::Pregnancy qw(calculate_month); $month = calculate_month(first_day_of_last_period => $dt); $month = calculate_month( first_day_of_last_period => $dt, date => $dt2, ); $month = calculate_month( first_day_of_last_period => $dt, method => 'countback', ); $week = calculate_month(birthday => $birthday); =head1 DESCRIPTION This module can be used to calculate the due date for a pregnancy, it implements 3 different methods, which will give different results. The different methods are described below in detail (SEE: METHODS). This module relies heavily on DateTime objects in order to calculate dates of birth, week numbers and month numbers. It does however not require Michael Schwern's module L. =head2 calculate_birthday Calculates date of birth. Takes one named parameter: * first_day_of_last_period Which should be a DateTime object indicating the first day of the last period. If the period cycle length varies from the average of 28 days, you can optionally provide the named parameter: * period_cycle_length This defaults to 28. The default method used for calculating date of birth is the 266 days method (SEE: Methods). If you want to use one of the other methods you can use the named parameter B and specify either: * 40weeks * countback The function returns a DateTime object indicating the calculated date of birth or undef upon failure. =head2 calculate_week Calculates in what week the pregnant person currently is. A pregnancy is on average 40 weeks; these week numbers are normally used when talking pregnancy and most guides, books and websites refer to the different stages of pregnancy using these week numbers. Takes one named parameter: * first_day_of_last_period Which should be a DateTime object indicating the first day of the last period. Optionally you can provide it with a named B parameter if you want to calculate the week number for a given date. The date specified should be a DateTime object, this defaults to now, when not provided. Also a named parameter called B can be provided, if you already have a birthday DateTime object. If this is not provided B will call B internally. As for B the function also takes the named parameter: * first_day_of_last_period and * method Please refer to B. The function returns an integer indicating the week of the pregnancy or undef upon failure. =head2 calculate_month Calculates in what month the pregnant person currently is (see also B). A pregnancy is on average 9 months. Takes one named parameter: * first_day_of_last_period Which should be a DateTime object indicating the first day of the last period. Optionally you can provide it with a named B parameter if you want to calculate the month number for a given date. The date specified should be a DateTime object, this defaults to now, when not provided. Also a named parameter called B can be provided, as for B, if you already have a birthday DateTime object. If this is not provided B will call B internally. As for B the function also takes the named parameter: * first_day_of_last_period and * method Please refer to B. The function returns an integer indicating the month of the pregnancy or undef upon failure. =head1 METHODS This module implements 3 different methods for calculating the date of birth based on data such as first day of last period (LMP) and average period cycle length (APCL). The 3 methods are: =over =item 266 Days (the one used by default) =item 40 Weeks =item Count Back =back =head2 266 Days This method uses the APCL together with the LMP. It adds the APCL divided by 2 to the LMP in the case where APCL is equal to or lower than the average of 28 days. In the case where the APCL is higher than the average it adds the APCL multiplied by 0.85 multiplied by 2 divided by 3 to the LMP. =head2 40 Weeks This method does not use the APCL, but simply counts 40 weeks, the number of weeks in an average pregnancy from the LMP date. =head2 Count Back The count back method adds 7 days to the LMP, then deducts 3 months, and finally adds 1 year to give the estimated date of birth. =head1 TEST DATA I am very interested in improving this module, so if you have the opportunity of submitting me test data it is more than welcome. The format should be either a test file (*.t), where you choose the file name yourself (see t/Villads.t) or you simply submit me the date of the first day of the last period for the pregnant person, the length of time between periods (if this varies from the avarage of 28), and possibly the result of your own/your doctor's week number calculation. I can then use these data to validate the calculation methods used in this module. If possible please include the information on what method your doctor is using if this is available (SEE: METHODS). =head1 BUGS Please report issues via CPAN RT: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-Pregnancy or by sending mail to bug-Date-Pregnancy@rt.cpan.org See the BUGS file for known bugs. =head1 SEE ALSO =over =item L =item L =item L =item L =item L =item L =back =head1 DISCLAIMER The method of calculating day of birth and week numbers implemented in this module is based on simple formulas. The ultrasound scan is a much more accurate method and finally babies seem to have a will of their own, so please do only use the results of this module as a guideline, the author of this module cannot be held responsible for the results of calculations based on use of this module. Feedback is welcome though as well as test data (please see TEST DATA above). =head1 ACKNOWLEDGEMENTS =over =item * Nick Morrott, corrections to multiple spelling errors =item * Thomas Eibner, who ALWAYS asks me whether I am a father by now and acuses me of pregnant-talk (just because he cannot calculate the weeks), now he can find out by looking at the tests included in this module or by using this module. =item * Lars Balker Rasmussen, who could not find Date-Pregnancy in his include path "lbr can't locate Date/Pregnancy.pm in @INC" - Now he has no excuse L is a reality. =item * Lars Thegler for making me revisit the alpha version. =back =head1 AUTHOR Jonas B. Nielsen, (jonasbn) - C<< >> =head1 COPYRIGHT Date-Pregnancy is (C) by Jonas B. Nielsen, (jonasbn) 2004-2016 Date-Pregnancy is released under the artistic license 2.0 =cut calculate_birthday.t100644000765000024 247112660554236 20527 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t# $Id$ use strict; use Test::More tests => 17; use DateTime; #test 1 use_ok( "Date::Pregnancy", qw(calculate_birthday)); my $dt = DateTime->new( year => 2004, month => 3, day => 19, ); my $birthday; #test 2 ok($birthday = calculate_birthday( first_day_of_last_period => $dt, )); #test 3 isa_ok($birthday, "DateTime"); #test 4 ok($birthday = calculate_birthday( first_day_of_last_period => $dt, period_cycle_length => 28, )); #test 5 isa_ok($birthday, "DateTime"); #test 6 is(calculate_birthday(), undef); #test 7 ok($birthday = calculate_birthday( first_day_of_last_period => $dt, method => '40weeks', )); #test 8 isa_ok($birthday, "DateTime"); #test 9 ok($birthday = calculate_birthday( first_day_of_last_period => $dt, method => '266days', )); #test 10 isa_ok($birthday, "DateTime"); #test 11 ok($birthday = calculate_birthday( first_day_of_last_period => $dt, method => '266days', period_cycle_length => 28, )); #test 12 isa_ok($birthday, "DateTime"); #test 13 ok($birthday = calculate_birthday( first_day_of_last_period => $dt, method => '266days', period_cycle_length => 29, )); #test 14 isa_ok($birthday, "DateTime"); #test 15-17 is($birthday->day, 26); is($birthday->year, 2004); is($birthday->month, 12); release-pod-syntax.t100644000765000024 45612660554236 20411 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); release-pod-coverage.t100644000765000024 57212660554236 20655 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); release-cpan-changes.t100644000765000024 52112660554236 20623 0ustar00jonasbnstaff000000000000Date-Pregnancy-0.06/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More 0.96 tests => 2; use_ok('Test::CPAN::Changes'); subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; done_testing();