Skip to content

A 29 February Birthday in a Common Year

  • The core functions, which every industry uses.

A 29 February Birthday in a Common Year

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

The naive approach

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

Watch it break

The naive approach silently produces wrong results — there is no GMT equivalent to demonstrate because the failure is not using GMT.

Why

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.

The gmt approach

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"

Same widget, working

output 

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else:© 2026 NorthGuild, all rights reserved.