# A 29 February Birthday in a Common Year

Industry: Core

### A 29 February Birthday in a Common Year

Someone was born on 29 February 2000. When is their birthday in 2023?

The usual approach:
```js
// The naive approach: build the date in the year you need
const d = new Date(2023, 1, 29);
console.log(d.getMonth() + 1, d.getDate()); // 3 1
// 29 February 2023 rolls over to 1 March 2023. The day moved, and nothing said so.
```

A month-day has no year, so \`--02-29\` is a valid value. Placing it in a year that has no 29 February is a question with two common answers. Temporal's \`toPlainDate\` constrains it to the last day of February, and \`monthDayToDate\` does the same. Some rules and contracts use 1 March instead. That is the caller's policy, so the example ends with it as a function of the year rather than a gmt option.

With GMT:
```js
import { monthDayToDate, addDate } from "@northguild/gmt";

monthDayToDate("--02-29", 2023); // "2023-02-28"
monthDayToDate("--02-29", 2024); // "2024-02-29"

// The 1 March policy
const birthdayOnFirstOfMarch = (year) => {
  const date = monthDayToDate("--02-29", year);
  return date.endsWith("-02-29") ? date : addDate(date, { days: 1 });
};
birthdayOnFirstOfMarch(2023); // "2023-03-01"
birthdayOnFirstOfMarch(2024); // "2024-02-29"
```
