> ## Documentation Index
> Fetch the complete documentation index at: https://starrycodes.mintlify.app/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.

<Steps titleSize="h3">
  <Step title="🗓️ Simple Duration">
    <ResponseField name="addDays(int days)" type="DateTime">
      <Card>
        <ParamField body="days" type="int" required>
          The number of days to add to the current `date`.
        </ParamField>
      </Card>

      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);
      ```
    </ResponseField>

    <ResponseField name="subtractDays(int days)" type="DateTime">
      <Card>
        <ParamField body="days" type="int" required>
          The number of days to subtract from the current `date`.
        </ParamField>
      </Card>

      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);
      ```
    </ResponseField>
  </Step>

  <Step title="📅 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).
    </Warning>

    <ResponseField name="addMonths(int months)" type="DateTime">
      <Card>
        <ParamField body="months" type="int" required>
          The number of months to add to the current `date`.
        </ParamField>
      </Card>

      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);
      ```
    </ResponseField>

    <ResponseField name="subtractMonths(int months)" type="DateTime">
      <Card>
        <ParamField body="months" type="int" required>
          The number of months to subtract from the current `date`.
        </ParamField>
      </Card>

      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);
      ```
    </ResponseField>

    <ResponseField name="addYears(int years)" type="DateTime">
      <Card>
        <ParamField body="years" type="int" required>
          The number of years to add to the current `date`.
        </ParamField>
      </Card>

      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);
      ```
    </ResponseField>

    <ResponseField name="subtractYears(int years)" type="DateTime">
      <Card>
        <ParamField body="years" type="int" required>
          The number of years to subtract from the current `date`.
        </ParamField>
      </Card>

      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);
      ```
    </ResponseField>
  </Step>

  <Step title="💼 Business Days">
    <ResponseField name="addBusinessDays(int days)" type="DateTime">
      <Card>
        <ParamField body="days" type="int" required>
          The number of business days to add.
        </ParamField>
      </Card>

      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);
      ```
    </ResponseField>
  </Step>
</Steps>
