Date::Pregnancy(3pm)

πŸ“¦
version 0.06 Β· 2 versions
  • 0.06 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.06 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Date::Pregnancy ✨

okay so bestie, welcome to the Date::Pregnancy page β€” it's the 3pm manual, which means it's a Perl module doc, and it's genuinely one of the cutest little things you'll ever use in your life πŸΌπŸ’–

🌸 NAME 🌸

Date::Pregnancy β€” calculate birthdate and week numbers for a pregnancy. yes, really. it does the math so you don't have to sit there with a calendar going "wait. wait. what week is it" 😭

πŸŽ€ VERSION πŸŽ€

This documentation describes version 0.05.


✨ SYNOPSIS ✨

here's the whole vibe, verbatim, so you can copy-paste and go off:

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);

(yes, that last line really does say calculate_month assigned into $week. it's giving chaos, we respect it, we keep it exactly as written 🫢)


πŸ’… DESCRIPTION πŸ’…

This module is your little due-date calculator bestie πŸ’– it works out the due date for a pregnancy, and it ships with 3 different methods, which β€” heads up β€” will give you different results. not a bug, just math being math.

The different methods get described in detail further down (SEE: METHODS πŸ‘€).

This module relies heavily on DateTime objects to do all its date-of-birth, week-number and month-number math. It does however not require Michael Schwern's module Sex. iconic. no notes 😌

🌼 calculate_birthday 🌼

Calculates date of birth. the main event, the moment, the πŸ‘‘

Takes one named parameter:

  • first_day_of_last_period β€” should be a DateTime object marking the first day of the last period.

If the period cycle length varies from the average of 28 days, you can optionally hand it the named parameter:

  • period_cycle_length β€” defaults to 28.

The default method used for calculating date of birth is the 266 days method (SEE: Methods). If you want one of the other methods, use the named parameter method and specify either:

  • 40weeks
  • countback

The function returns a DateTime object with the calculated date of birth, or undef upon failure πŸ’€

πŸ¦‹ calculate_week πŸ¦‹

Calculates what week the pregnant person is currently in. A pregnancy is on average 40 weeks; these week numbers are the ones everyone actually uses when talking pregnancy, and most guides, books and websites refer to the different stages of pregnancy using these week numbers. so yeah, this is the number people mean πŸ“†βœ¨

Takes one named parameter:

  • first_day_of_last_period β€” should be a DateTime object marking the first day of the last period.

Optionally you can give it a named date parameter if you want the week number for a specific date. The date you specify should be a DateTime object, and it defaults to now when not provided.

Also, a named parameter called birthday can be provided, if you already have a birthday DateTime object. If it's not provided, calculate_week will call calculate_birthday internally. teamwork 🫢

As for calculate_birthday, the function also takes the named parameter:

  • first_day_of_last_period

and

  • method

Please refer to calculate_birthday.

The function returns an integer for the week of the pregnancy, or undef upon failure.

🌸 calculate_month 🌸

Calculates what month the pregnant person is currently in (see also calculate_week). A pregnancy is on average 9 months.

Takes one named parameter:

  • first_day_of_last_period β€” should be a DateTime object marking the first day of the last period.

Optionally you can give it a named date parameter if you want the month number for a specific date. The date you specify should be a DateTime object, and it defaults to now when not provided.

Also, a named parameter called birthday can be provided, same as for calculate_week, if you already have a birthday DateTime object. If it's not provided, calculate_month will call calculate_birthday internally.

As for calculate_birthday, the function also takes the named parameter:

  • first_day_of_last_period

and

  • method

Please refer to calculate_birthday.

The function returns an integer for the month of the pregnancy, or undef upon failure.


πŸ”₯ METHODS πŸ”₯

This module implements 3 different methods for calculating the date of birth, based on data like first day of last period (LMP) and average period cycle length (APCL). acronyms, we love them πŸ’…

The 3 methods are:

  1. 266 Days (the one used by default)
  2. 40 Weeks
  3. Count Back

⭐ 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.

⭐ 40 Weeks ⭐

This method does not use the APCL β€” it simply counts 40 weeks, the number of weeks in an average pregnancy, from the LMP date. no fancy math, just vibes and counting πŸ“†

⭐ 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.


🧚 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).


πŸ’€ 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.


🌈 SEE ALSO 🌈


🫢 DISCLAIMER 🫢

The method of calculating day of birth and week numbers implemented in this module is based on simple formulas. simple! formulas! that's the whole thing.

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.

fr fr bestie β€” this is a guideline, not a prophecy. the baby has main character energy and will arrive whenever it wants πŸ‘ΆπŸ’…

Feedback is welcome though as well as test data (please see TEST DATA above).


πŸ‘‘ ACKNOWLEDGEMENTS πŸ‘‘

  • Nick Morrott, corrections to multiple spelling errors
  • 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.
  • 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 Date::Pregnancy is a reality.
  • Lars Thegler for making me revisit the alpha version.

πŸ’œ AUTHOR πŸ’œ

Jonas B. Nielsen, (jonasbn) β€” <jonasbn@cpan.org>


Date-Pregnancy is (C) by Jonas B. Nielsen, (jonasbn) 2004-2016

Date-Pregnancy is released under the artistic license 2.0


and that's a wrap, bestie πŸŽ€ this was Date::Pregnancy(3pm) from perl v5.34.0, dated 2022-06-13 β€” go calculate something cute, and remember: the vibes are a guideline, the facts are canon πŸ’–βœ¨