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

# Package datetime

> Reference documentation for Indie datetime package. Covers datetime, time, and timedelta types with field definitions and method specifications.

export const Anchor = ({id}) => {
  return <div id={id} style={{
    scrollMarginTop: "var(--scroll-mt)"
  }}></div>;
};

export const Field = ({id, name, type, required, defaultVal, children}) => {
  return <div id={id} style={{
    scrollMarginTop: "var(--scroll-mt)"
  }} className="mt-4">
      <div className="pt-2.5 pb-5 my-2.5 border-gray-50 dark:border-gray-800/50 border-b">
        <div className="flex font-mono text-sm group/param-head param-head">
          <div className="flex-1 flex content-start py-0.5 mr-5">
            <div className="flex items-center flex-wrap gap-2">
              {id && <div className="absolute">
                  <a href={`#${id}`} className="-ml-10 flex items-center opacity-0 border-0 group-hover/param-head:opacity-100 py-2" aria-label={`Navigate to ${id}`}>
                    <div className="w-6 h-6 text-gray-400 rounded-md flex items-center justify-center zinc-box bg-white ring-1 ring-gray-400/30 dark:ring-gray-700/25 hover:ring-gray-400/60 dark:hover:ring-white/20">
                      <svg xmlns="http://www.w3.org/2000/svg" fill="gray" height="12px" viewBox="0 0 576 512">
                        <path d="M0 256C0 167.6 71.6 96 160 96h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C98.1 144 48 194.1 48 256s50.1 112 112 112h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C71.6 416 0 344.4 0 256zm576 0c0 88.4-71.6 160-160 160H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c61.9 0 112-50.1 112-112s-50.1-112-112-112H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c88.4 0 160 71.6 160 160zM184 232H392c13.3 0 24 10.7 24 24s-10.7 24-24 24H184c-13.3 0-24-10.7-24-24s10.7-24 24-24z"></path>
                      </svg>
                    </div>
                  </a>
                </div>}
              <div className="font-semibold text-primary dark:text-primary-light">
                {name}
              </div>
              <div className="flex items-center space-x-2 text-xs font-medium">
                <div className="flex items-center px-2 py-0.5 rounded-md bg-gray-100/50 dark:bg-white/5 text-gray-600 dark:text-gray-200 font-medium">
                  {type}
                </div>
                {required && <span className="px-2 py-0.5 rounded-md bg-red-100/50 dark:bg-red-400/10 text-red-600 dark:text-red-300 font-medium">
                    required
                  </span>}
                {defaultVal && <div className="flex items-center px-2 py-0.5 rounded-md bg-gray-100/50 dark:bg-white/5 text-gray-600 dark:text-gray-200 font-medium">
                    <span class="text-gray-400 dark:text-gray-500">default:</span>
                    {defaultVal}
                  </div>}
              </div>
            </div>
          </div>
        </div>
        <div className="mt-4 prose-sm prose-gray dark:prose-invert">
          {children}
        </div>
      </div>
    </div>;
};

The datetime package supplies classes for manipulating dates and times.

<Note>See description in the [official Python docs](https://docs.python.org/3.10/library/datetime.html).</Note>

***

## Types

<Anchor id="class_datetime" />

### `datetime`

*type*

Represents date and time information.

<Steps>
  <Step title="Fields" icon="key">
    <Field id="field_datetime_year" name="year" type="int">
      The year value of the datetime object.
    </Field>

    <Field id="field_datetime_month" name="month" type="int">
      The month value of the datetime object.
    </Field>

    <Field id="field_datetime_day" name="day" type="int">
      The day value of the datetime object.
    </Field>

    <Field id="field_datetime_hour" name="hour" type="int">
      The hour value of the datetime object.
    </Field>

    <Field id="field_datetime_minute" name="minute" type="int">
      The minute value of the datetime object.
    </Field>

    <Field id="field_datetime_second" name="second" type="int">
      The second value of the datetime object.
    </Field>

    <Field id="field_datetime_microsecond" name="microsecond" type="int">
      The microsecond value of the datetime object.
    </Field>
  </Step>

  <Step title="Methods" icon="function">
    <Field id="method_datetime_init" name="__init__" type="(year, month, day, hour, minute, second, microsecond) -> None">
      Class constructor (initializer for the data type).

      <Expandable title="parameters info">
        <Field name="year" type="int" required>
          Year value.
        </Field>

        <Field name="month" type="int" required>
          Month value.
        </Field>

        <Field name="day" type="int" required>
          Day value.
        </Field>

        <Field name="hour" type="int" defaultVal="0">
          Hour value.
        </Field>

        <Field name="minute" type="int" defaultVal="0">
          Minute value.
        </Field>

        <Field name="second" type="int" defaultVal="0">
          Second value.
        </Field>

        <Field name="microsecond" type="int" defaultVal="0">
          Microsecond value.
        </Field>
      </Expandable>
    </Field>

    <Field id="method_datetime_timestamp" name="timestamp" type="() -> float">
      Returns the total number of seconds since the Unix epoch.
    </Field>

    <Field id="method_datetime_weekday" name="weekday" type="() -> int">
      Returns the day of the week as an integer, where Monday is 0 and Sunday is 6.
    </Field>

    <Field id="method_datetime_add" name="__add__" type="(delta) -> datetime.datetime">
      `+` operator for `datetime` objects.

      <Expandable title="parameters info">
        <Field name="delta" type="datetime.timedelta" required>
          Timedelta to add to the current datetime.
        </Field>
      </Expandable>
    </Field>

    <Field id="method_datetime_sub" name="__sub__" type="(delta) -> datetime.datetime">
      `-` operator for `datetime` objects.

      <Expandable title="parameters info">
        <Field name="delta" type="datetime.timedelta" required>
          Timedelta to subtract from the current datetime.
        </Field>
      </Expandable>
    </Field>

    <Field name="__sub__" type="(other) -> datetime.timedelta">
      `-` operator for `datetime` objects.

      <Expandable title="parameters info">
        <Field name="other" type="datetime.datetime" required>
          Datetime to subtract from the current datetime.
        </Field>
      </Expandable>
    </Field>
  </Step>

  <Step title="Static methods" icon="cubes">
    <Field id="method_datetime_utcfromtimestamp" name="utcfromtimestamp" type="(timestamp) -> datetime.datetime">
      Returns the UTC datetime corresponding to the POSIX timestamp.

      <Expandable title="parameters info">
        <Field name="timestamp" type="float" required>
          Timestamp in UTC.
        </Field>
      </Expandable>
    </Field>

    <Field id="method_datetime_strptime" name="strptime" type="(date_string, format) -> datetime.datetime">
      Returns a datetime corresponding to `date_string`, parsed according to `format`.

      <Expandable title="parameters info">
        <Field name="date_string" type="str" required>
          Datetime to parse.
        </Field>

        <Field name="format" type="str" required>
          Datetime format. Supported codes: `%Y`, `%y`, `%m`, `%b`, `%d`, `%H`, `%I`, `%M`, `%S`, `%p`, `%f`, `%z`. See more details [here](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes).
        </Field>
      </Expandable>
    </Field>
  </Step>
</Steps>

***

<Anchor id="class_time" />

### `time`

*type*

Represents a time of day, independent of any particular day.

<Steps>
  <Step title="Fields" icon="key">
    <Field id="field_time_hour" name="hour" type="int">
      The hour value of the time object.
    </Field>

    <Field id="field_time_minute" name="minute" type="int">
      The minute value of the time object.
    </Field>

    <Field id="field_time_second" name="second" type="int">
      The second value of the time object.
    </Field>

    <Field id="field_time_microsecond" name="microsecond" type="int">
      The microsecond value of the time object.
    </Field>
  </Step>

  <Step title="Methods" icon="function">
    <Field id="method_time_init" name="__init__" type="(hour, minute, second, microsecond) -> None">
      Class constructor (initializer for the data type).

      <Expandable title="parameters info">
        <Field name="hour" type="int" defaultVal="0">
          Hour value.
        </Field>

        <Field name="minute" type="int" defaultVal="0">
          Minute value.
        </Field>

        <Field name="second" type="int" defaultVal="0">
          Second value.
        </Field>

        <Field name="microsecond" type="int" defaultVal="0">
          Microsecond value.
        </Field>
      </Expandable>
    </Field>

    <Field id="method_time_add" name="__add__" type="(delta) -> datetime.datetime">
      `+` operator for `time` objects.

      <Expandable title="parameters info">
        <Field name="delta" type="datetime.timedelta" required>
          Timedelta to add to the current time.
        </Field>
      </Expandable>
    </Field>

    <Field id="method_time_sub" name="__sub__" type="(delta) -> datetime.datetime">
      `-` operator for `time` objects.

      <Expandable title="parameters info">
        <Field name="delta" type="datetime.timedelta" required>
          Timedelta to subtract from the current time.
        </Field>
      </Expandable>
    </Field>
  </Step>
</Steps>

***

<Anchor id="class_timedelta" />

### `timedelta`

*type*

A timedelta object represents a duration, the difference between two datetimes.

<Steps>
  <Step title="Fields" icon="key">
    <Field id="field_timedelta_days" name="days" type="int">
      The days value of the timedelta object.
    </Field>

    <Field id="field_timedelta_seconds" name="seconds" type="int">
      The seconds value of the timedelta object.
    </Field>

    <Field id="field_timedelta_microseconds" name="microseconds" type="int">
      The microseconds value of the timedelta object.
    </Field>
  </Step>

  <Step title="Methods" icon="function">
    <Field id="method_timedelta_init" name="__init__" type="(days, seconds, microseconds, milliseconds, minutes, hours, weeks) -> None">
      Class constructor (initializer for the data type).

      <Expandable title="parameters info">
        <Field name="days" type="int" defaultVal="0">
          Number of days.
        </Field>

        <Field name="seconds" type="int" defaultVal="0">
          Number of seconds.
        </Field>

        <Field name="microseconds" type="int" defaultVal="0">
          Number of microseconds.
        </Field>

        <Field name="milliseconds" type="int" defaultVal="0">
          Number of milliseconds.
        </Field>

        <Field name="minutes" type="int" defaultVal="0">
          Number of minutes.
        </Field>

        <Field name="hours" type="int" defaultVal="0">
          Number of hours.
        </Field>

        <Field name="weeks" type="int" defaultVal="0">
          Number of weeks.
        </Field>
      </Expandable>
    </Field>

    <Field id="method_timedelta_total_seconds" name="total_seconds" type="() -> float">
      Returns the total number of seconds contained in the duration.
    </Field>
  </Step>
</Steps>

***
