> ## Documentation Index
> Fetch the complete documentation index at: https://starrycodes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DateTime - Manipulation Extensions

> Simplified methods for adding/subtracting days, months, and years, plus a critical utility for calculating future business days.

### 1. 🗓️ Simple Duration

**addDays(int days)** `DateTime`

> [card]
>
> **days** `int` *required*
>
> The number of days to add to the current `date`.

Adds a number of days to the current `DateTime` object.

```dart lines wrap theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
final futureDate = DateTime.now().addDays(5);
```

**subtractDays(int days)** `DateTime`

> [card]
>
> **days** `int` *required*
>
> The number of days to subtract from the current `date`.

Subtracts a number of days from the current `DateTime` object.

```dart lines wrap theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
final pastDate = DateTime.now().subtractDays(10);
```

### 2. 📅 Calendar Components (Use with Caution)

> [!WARNING]
>
> Be cautious with `addMonths` and `addYears`. Dart's `DateTime` constructor handles invalid days (like Feb 30th) by overflowing to the next month/year. Always test edge cases (e.g., Jan 31st + 1 month = Mar 3rd).

**addMonths(int months)** `DateTime`

> [card]
>
> **months** `int` *required*
>
> The number of months to add to the current `date`.

Adds a number of months. (*Warning: Susceptible to date overflow errors.*)

```dart lines wrap theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
// Goes from March 15th to June 15th
final newDate = DateTime(2025, 3, 15).addMonths(3);
```

**subtractMonths(int months)** `DateTime`

> [card]
>
> **months** `int` *required*
>
> The number of months to subtract from the current `date`.

Subtracts a number of months. (*Warning: Susceptible to date overflow errors.*)

```dart lines wrap theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
// Goes from May 20th to February 20th
final pastDate = DateTime(2025, 5, 20).subtractMonths(3);
```

**addYears(int years)** `DateTime`

> [card]
>
> **years** `int` *required*
>
> The number of years to add to the current `date`.

Adds a number of years. (*Warning: Be mindful of leap years.*)

```dart lines wrap theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
final futureYear = DateTime.now().addYears(5);
```

**subtractYears(int years)** `DateTime`

> [card]
>
> **years** `int` *required*
>
> The number of years to subtract from the current `date`.

Subtracts a number of years. (*Warning: Be mindful of leap years.*)

```dart lines wrap theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
final pastYear = DateTime.now().subtractYears(2);
```

### 3. 💼 Business Days

**addBusinessDays(int days)** `DateTime`

> [card]
>
> **days** `int` *required*
>
> The number of business days to add.

Adds a number of business days (Monday to Friday) to the current `date`, automatically skipping weekends.

```dart lines wrap theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
// If today is Friday, adding 1 business day results in Monday.
final nextWorkDay = DateTime(2025, 11, 28).addBusinessDays(1);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.