> ## 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

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

***

## Types

### `datetime`

*type*

Represents date and time information.

**1. Fields**

[Navigate to field\_datetime\_year](#field_datetime_year)

year

int

The year value of the datetime object.

[Navigate to field\_datetime\_month](#field_datetime_month)

month

int

The month value of the datetime object.

[Navigate to field\_datetime\_day](#field_datetime_day)

day

int

The day value of the datetime object.

[Navigate to field\_datetime\_hour](#field_datetime_hour)

hour

int

The hour value of the datetime object.

[Navigate to field\_datetime\_minute](#field_datetime_minute)

minute

int

The minute value of the datetime object.

[Navigate to field\_datetime\_second](#field_datetime_second)

second

int

The second value of the datetime object.

[Navigate to field\_datetime\_microsecond](#field_datetime_microsecond)

microsecond

int

The microsecond value of the datetime object.

**2. Methods**

[Navigate to method\_datetime\_init](#method_datetime_init)

**init**

(year, month, day, hour, minute, second, microsecond) -> None

Class constructor (initializer for the data type).

**parameters info**

year

int

required

Year value.

month

int

required

Month value.

day

int

required

Day value.

hour

int

default:
0

Hour value.

minute

int

default:
0

Minute value.

second

int

default:
0

Second value.

microsecond

int

default:
0

Microsecond value.

[Navigate to method\_datetime\_timestamp](#method_datetime_timestamp)

timestamp

() -> float

Returns the total number of seconds since the Unix epoch.

[Navigate to method\_datetime\_weekday](#method_datetime_weekday)

weekday

() -> int

Returns the day of the week as an integer, where Monday is 0 and Sunday is 6.

[Navigate to method\_datetime\_add](#method_datetime_add)

**add**

(delta) -> datetime.datetime

`+` operator for `datetime` objects.

**parameters info**

delta

datetime.timedelta

required

Timedelta to add to the current datetime.

[Navigate to method\_datetime\_sub](#method_datetime_sub)

**sub**

(delta) -> datetime.datetime

`-` operator for `datetime` objects.

**parameters info**

delta

datetime.timedelta

required

Timedelta to subtract from the current datetime.

**sub**

(other) -> datetime.timedelta

`-` operator for `datetime` objects.

**parameters info**

other

datetime.datetime

required

Datetime to subtract from the current datetime.

**3. Static methods**

[Navigate to method\_datetime\_utcfromtimestamp](#method_datetime_utcfromtimestamp)

utcfromtimestamp

(timestamp) -> datetime.datetime

Returns the UTC datetime corresponding to the POSIX timestamp.

**parameters info**

timestamp

float

required

Timestamp in UTC.

[Navigate to method\_datetime\_strptime](#method_datetime_strptime)

strptime

(date\_string, format) -> datetime.datetime

Returns a datetime corresponding to `date_string`, parsed according to `format`.

**parameters info**

date\_string

str

required

Datetime to parse.

format

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

***

### `time`

*type*

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

**1. Fields**

[Navigate to field\_time\_hour](#field_time_hour)

hour

int

The hour value of the time object.

[Navigate to field\_time\_minute](#field_time_minute)

minute

int

The minute value of the time object.

[Navigate to field\_time\_second](#field_time_second)

second

int

The second value of the time object.

[Navigate to field\_time\_microsecond](#field_time_microsecond)

microsecond

int

The microsecond value of the time object.

**2. Methods**

[Navigate to method\_time\_init](#method_time_init)

**init**

(hour, minute, second, microsecond) -> None

Class constructor (initializer for the data type).

**parameters info**

hour

int

default:
0

Hour value.

minute

int

default:
0

Minute value.

second

int

default:
0

Second value.

microsecond

int

default:
0

Microsecond value.

[Navigate to method\_time\_add](#method_time_add)

**add**

(delta) -> datetime.datetime

`+` operator for `time` objects.

**parameters info**

delta

datetime.timedelta

required

Timedelta to add to the current time.

[Navigate to method\_time\_sub](#method_time_sub)

**sub**

(delta) -> datetime.datetime

`-` operator for `time` objects.

**parameters info**

delta

datetime.timedelta

required

Timedelta to subtract from the current time.

***

### `timedelta`

*type*

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

**1. Fields**

[Navigate to field\_timedelta\_days](#field_timedelta_days)

days

int

The days value of the timedelta object.

[Navigate to field\_timedelta\_seconds](#field_timedelta_seconds)

seconds

int

The seconds value of the timedelta object.

[Navigate to field\_timedelta\_microseconds](#field_timedelta_microseconds)

microseconds

int

The microseconds value of the timedelta object.

**2. Methods**

[Navigate to method\_timedelta\_init](#method_timedelta_init)

**init**

(days, seconds, microseconds, milliseconds, minutes, hours, weeks) -> None

Class constructor (initializer for the data type).

**parameters info**

days

int

default:
0

Number of days.

seconds

int

default:
0

Number of seconds.

microseconds

int

default:
0

Number of microseconds.

milliseconds

int

default:
0

Number of milliseconds.

minutes

int

default:
0

Number of minutes.

hours

int

default:
0

Number of hours.

weeks

int

default:
0

Number of weeks.

[Navigate to method\_timedelta\_total\_seconds](#method_timedelta_total_seconds)

total\_seconds

() -> float

Returns the total number of seconds contained in the duration.

***


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