# Is 2/29 an invalid birth date?

**URL:** <https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370>\
**Category:** Factual Questions\
**Created:** [February 29, 2012, 6:18pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370 "2012-02-29T18:18:09Z")\
**Posts on this page:** 14\
**Page:** 3

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [March 1, 2012, 4:40pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/41 "2012-03-01T16:40:57Z")

</div>

> [@UncleRojelio](#):
>
> ```auto
> 
> if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
> return 1; /* leap */
> else
> return 0; /* no leap */
> 
> ```

This is wrong. It does not account for dates prior to 1582. It also fails to use your programming environment’s built-in calendar arithmetic library, which is wrong by definition, even if your algorithm is correct.

---

<div class="post-metadata">

**Author:** ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)\
**Post date:** [March 1, 2012, 4:55pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/42 "2012-03-01T16:55:34Z")

</div>

> [@friedo](#):
>
> This is wrong. It does not account for dates prior to 1582. It also fails to use your programming environment’s built-in calendar arithmetic library, which is wrong by definition, even if your algorithm is correct.

For that matter, presuming 1582 for the Gregorian shift is wrong, if you are interested in historic calendar dates. It is locale dependent. For instance, 1752 was the year England switched. They also changed the beginning of the year from March 25 to Jan 1 at the same time, which your standard library may not reflect.

Yes, one should use the available date arithmetic routines, if they are available, and sufficiently aware for your purposes. Otherwise, realize that date and time manipulation routines are a bloody morass, not because of the computational complexity for any single rule, but because of the ad-hoc changing of rules by regional authorities.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [March 1, 2012, 5:04pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/43 "2012-03-01T17:04:38Z")

</div>

> [@friedo](#):
>
> This is wrong. It does not account for dates prior to 1582.

1582? Damnable Papist! More than a few in the _Christian_ world did not transition until 1700, and did not transition _fully_ until 1776; the Orthodox Catholics in Greece didn’t change until 1923.

The larger question, though, is whether your air traffic control system needs to care that dates prior to its creation may or may not be considered ‘leap’ depending on where it is eventually shipped.

---

<div class="post-metadata">

**Author:** ![Driver8](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@Driver8](https://boards.straightdope.com/u/Driver8)\
**Post date:** [March 1, 2012, 5:05pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/44 "2012-03-01T17:05:53Z")

</div>

> [@Musicat](#):
>
> As a programmer, I can tell you that accounting for this kind of error is one of the most trivial routines imaginable. To not do so is either ignorance or laziness. Don’t they teach the modern calendar in computer science class anymore?

Everything you say is true, but 32 years of no middle name and a surname with a space in it have taught me never to underestimate the laziness and ignorance of programmers!

(No offense intended, I’m a programmer myself).

---

<div class="post-metadata">

**Author:** ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)\
**Post date:** [March 1, 2012, 5:13pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/45 "2012-03-01T17:13:40Z")

</div>

> [@Derleth](#):
>
> 1582? Damnable Papist! More than a few in the _Christian_ world did not transition until 1700, and did not transition _fully_ until 1776; the Orthodox Catholics in Greece didn’t change until 1923.
> 
> The larger question, though, is whether your air traffic control system needs to care that dates prior to its creation may or may not be considered ‘leap’ depending on where it is eventually shipped.

The timeline of Gregorian adoption is very piecemeal:  
[![](https://upload.wikimedia.org/wikipedia/en/timeline/2428bfc1385744ace6c5f9ebafdcd154.png) ](https://upload.wikimedia.org/wikipedia/en/timeline/2428bfc1385744ace6c5f9ebafdcd154.png)

And Sweden is a really complicated special case:

> **[Swedish calendar](https://en.wikipedia.org/wiki/Swedish_calendar)**
>
> The Swedish calendar (Swedish: svenska kalendern) or Swedish style (svenska stilen) was a calendar in use in Sweden and its possessions from 1 March 1700 until 30 February 1712. It was one day ahead of the Julian calendar and ten days behind the Gregorian calendar. Easter was calculated astronomically, with a minor exception, from 1740 to 1844.
> In November 1699, the Government of Sweden decided that, rather than adopt the Gregorian calendar outright, it would gradually approach it over a 40-year...

Yeah, many applications will (thankfully) not have to consider historical dates. Many WILL, however, have to consider DST switches, which modern governments have a penchant for messing with the rules for.

---

<div class="post-metadata">

**Author:** ![fiddlesticks](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/fiddlesticks/32/18129_2.png) [@fiddlesticks](https://boards.straightdope.com/u/fiddlesticks)\
**Post date:** [March 1, 2012, 5:16pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/46 "2012-03-01T17:16:35Z")

</div>

> [@Derleth](#):
>
> 1582? Damnable Papist! More than a few in the _Christian_ world did not transition until 1700, and did not transition _fully_ until 1776; the Orthodox Catholics in Greece didn’t change until 1923.
> 
> The larger question, though, is whether your air traffic control system needs to care that dates prior to its creation may or may not be considered ‘leap’ depending on where it is eventually shipped.

The Java GregorianCalendar class assumes October 5, 1582 by default, but has a method which you the programmer can set the change date to match which country your application is meant to represent.

Word of warning though, “However, dates obtained using GregorianCalendar are historically accurate only from March 1, 4 AD onward, when modern Julian calendar rules were adopted.” If you need a Calendar calculator more accurate than that, you’ll need to go seek out a third-party library.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [March 1, 2012, 5:30pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/47 "2012-03-01T17:30:20Z")

</div>

Don’t get me started on the proper use of floating timezones.

---

<div class="post-metadata">

**Author:** ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)\
**Post date:** [March 1, 2012, 5:52pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/48 "2012-03-01T17:52:59Z")

</div>

> [@fiddlesticks](#):
>
> The Java GregorianCalendar class assumes October 5, 1582 by default, but has a method which you the programmer can set the change date to match which country your application is meant to represent.
> 
> Word of warning though, “However, dates obtained using GregorianCalendar are historically accurate only from March 1, 4 AD onward, when modern Julian calendar rules were adopted.” If you need a Calendar calculator more accurate than that, you’ll need to go seek out a third-party library.

It also notes:

> [@](#):
>
> Prior to the institution of the Gregorian calendar, New Year’s Day was March 25. To avoid confusion, this calendar always uses January 1. A manual adjustment may be made if desired for dates that are prior to the Gregorian changeover and which fall between January 1 and March 24.

That isn’t accurate. The changeover from March 25 to Jan 1 was made independently of the Gregorian changeover in many countries, often before the adoption of the Gregorian calendar. Accommodating that was a headache that the implementer of GregorianCalendar chose to punt on, and I don’t blame them.

However the abstract java Calendar object provides a reasonably good definition for implementing calendar variants and hiding the considerations from the application programmer, provided you aren’t straying too far from the “12 months per year / 7 days per week” structure. You can actually manage to do date arithmetic with the thing in a semi-sane fashion, once you get the hang of it.

---

<div class="post-metadata">

**Author:** ![Colophon](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Colophon](https://boards.straightdope.com/u/Colophon)\
**Post date:** [March 1, 2012, 6:22pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/49 "2012-03-01T18:22:40Z")

</div>

> [@mangeorge](#):
>
> This has turned out to be much more interesting than I expected. But, buried in the OP, is a question; Does the federal government _require_ the parents to choose to enter either Februrary 28 or March 1, not Februrary 29 on the baby’s birth certificate?  
> Seems to me that would be depriving someone born on that of a pretty unique document and a cool talking point.

Googling turned up [this page](http://leapyearday.com/content/altered-birth-certificates) of anecdotes. It seems lots of mothers have tried to fiddle the date to avoid having a leap-year baby. I have no idea why - I think it would be a neat talking point.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [March 1, 2012, 6:45pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/50 "2012-03-01T18:45:45Z")

</div>

All you really need is a couple of functions to convert to and from Julian days (or any other simple linear timekeeping standard).

---

<div class="post-metadata">

**Author:** ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)\
**Post date:** [March 1, 2012, 7:26pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/51 "2012-03-01T19:26:01Z")

</div>

> [@Chronos](#):
>
> All you really need is a couple of functions to convert to and from Julian days (or any other simple linear timekeeping standard).

You have to be careful with using such a representation to perform arithmetic, though - one class of date bugs arises when somebody decides to calculate something like a one day interval (when you really mean “same time tomorrow”) by adding 86400 seconds to the current system time. If it crosses DST, you may want to add 23 hours or 25. If you don’t have a calendar object that directly handles date arithmetic, you have to muck around with today’s date to convert it, rather than something like:

cal.setTimeInMillis(System.currentTimeMillis());  
cal.add(Calendar.DAY\_OF\_MONTH,1);  
long wakeup = cal.getTimeInMillis();

The calendar object now takes care of you.

ETA:

Note that “time” in these java method names really means time and date, as ms since epoch.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [March 1, 2012, 9:05pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/52 "2012-03-01T21:05:34Z")

</div>

On the other hand, you might also have something you really do want to do 24 hours from now, regardless of DST. You just have to be careful about that sort of thing; no system is going to read your mind.

---

<div class="post-metadata">

**Author:** ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)\
**Post date:** [March 1, 2012, 9:21pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/53 "2012-03-01T21:21:58Z")

</div>

> [@Chronos](#):
>
> On the other hand, you might also have something you really do want to do 24 hours from now, regardless of DST. You just have to be careful about that sort of thing; no system is going to read your mind.

Understood. But the point is that an object or set of library routines to handle setting, adding, subtracting days, hours, etc while hiding DST / leap year / locale nastiness saves you a lot of headache. Particularly if you wind up writing stuff that handles user specified scheduling. Of course, I might also mention that my example would probably be more realistic using an actual time specification corresponding to the last event instead of System.currentTimeMillis(). If you calculated it that way as part of handling the scheduled event, the time would drift by the ms. to process your event each time. Not to mention having to be sure you don’t do something weird if the user changed their clock.

---

<div class="post-metadata">

**Author:** ![aruvqan](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/aruvqan/32/2891_2.png) [@aruvqan](https://boards.straightdope.com/u/aruvqan)\
**Post date:** [March 1, 2012, 11:43pm UTC](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370/54 "2012-03-01T23:43:57Z")

</div>

My ex husband was born on the 29th of Feb, and was in the Navy, so the government of Oregon and the US government both had no issues with it as a date.

[Previous page](https://boards.straightdope.com/t/is-2-29-an-invalid-birth-date/614370.md?page=2)
