# Days Old Counter

> Create a React component that calculates and displays how many days old a user is based on their birth date.

- Difficulty: intermediate
- Tags: useState, useEffect
- Estimated time: 30 minutes
- Tests: 4
- Requires subscription: yes

## Overview

Create a React component that calculates and displays how many days old a user is based on their birth date.


## Requirements

- Implement the `daysSinceBirth` function that takes a birth date string (`YYYY-MM-DD`) and returns the number of full days between that date and today. If the date is in the future, it should return 0.
- Add logic so that the counter updates automatically whenever a new date is selected in the provided input field.
- Ensure the counter starts at 0 when no date is selected.
- Animate the counter from 0 to the calculated value over the duration specified by `DURATION_MS`.


## Notes

- Handle edge cases such as future dates (the counter should not go negative).
- Make sure the counter updates correctly when the user changes the date multiple times.
- Use `requestAnimationFrame` for the counter animation instead of `setInterval` or `setTimeout`, as it ensures smooth updates and syncs with the browser's refresh rate.


## Tests

01. renders the app title
02. renders the counter initially at 0
03. calculates the correct target days for a given birth date
04. calculates days correctly using daysSinceBirth function with edge cases


