-
Notifications
You must be signed in to change notification settings - Fork 0
API Weekday
Concepts first: read Core Concepts before this page.
Signatures below are shown as the library declares them. From a script that imports it, every type and enum name takes your import alias: t.DateTime, t.Overflow.REJECT, t.Exchange.NYSE. A bare DateTime will not compile.
Weekday is an enum rather than a bare int because 0=Sunday versus 1=Monday confusion is the most common class of date bug. Three numbering schemes meet here and none of them agree: this library counts Sunday as 0, ISO-8601 counts Monday as 1, and Pine's own dayofweek counts Sunday as 1. to_int, to_iso_dow and to_pine_dow are the three ways out.
| Summary | |
|---|---|
abbr |
The three-letter English abbreviation of a weekday. |
days_until |
Forward distance in days from this weekday to another, never negative. |
minus |
The weekday n days earlier in the weekly cycle, wrapping. |
name |
The English name of a weekday. |
plus |
The weekday n days later in the weekly cycle, wrapping. |
to_int |
Numeric code for a weekday, 0 = Sunday through 6 = Saturday. |
to_iso_dow |
ISO-8601 numbering for this weekday, 1 = Monday through 7 = Sunday. |
to_pine_dow |
This weekday in Pine's own numbering, where Sunday is 1, the scale used by the dayofweek.* constants and returned by the dayofweek built-in. |
Weekday.abbr()
The three-letter English abbreviation of a weekday.
Returns The abbreviation, e.g. "Fri"..
Weekday.days_until(Weekday other)
Forward distance in days from this weekday to another, never negative. A method so the direction reads off the call: friday.days_until(monday).
| Parameter | Meaning |
|---|---|
other |
The target weekday. |
Returns Days to advance from this to reach other, in [0, 6]. Zero when they are the same day: a week later is not what "until" means here..
Weekday.minus(int n)
The weekday n days earlier in the weekly cycle, wrapping.
| Parameter | Meaning |
|---|---|
n |
Days to go back; may be negative. |
Returns The resulting Weekday..
Weekday.name()
The English name of a weekday.
Returns The full name, e.g. "Friday"..
Weekday.plus(int n)
The weekday n days later in the weekly cycle, wrapping.
| Parameter | Meaning |
|---|---|
n |
Days to advance; may be negative. |
Returns The resulting Weekday..
Weekday.to_int()
Numeric code for a weekday, 0 = Sunday through 6 = Saturday.
Returns Integer code in [0, 6]..
Weekday.to_iso_dow()
ISO-8601 numbering for this weekday, 1 = Monday through 7 = Sunday. One of three numbering schemes carried by this type: to_int() is 0-based Sunday-first, to_pine_dow() is Pine's 1-based Sunday-first, and this is ISO's 1-based Monday-first. All three live on the enum so a signature never has to say which scheme a bare int is in.
Returns ISO weekday in [1, 7]..
See also to_int, to_pine_dow
Weekday.to_pine_dow()
This weekday in Pine's own numbering, where Sunday is 1, the scale used by the dayofweek.* constants and returned by the dayofweek built-in. Distinct from to_int(), which is 0-based.
Returns An integer in [1, 7] comparable with dayofweek.monday and friends..
See also to_int
| Summary | |
|---|---|
Weekday |
Day of the week. |
enum
Day of the week. An enum rather than a bare int because 0=Sunday versus 1=Monday confusion is the most common class of date bug. Use .to_int() when the numeric code is needed.
| Member | Declared as | Meaning |
|---|---|---|
SUNDAY |
SUNDAY = "Sunday" |
Sunday, numeric code 0. |
MONDAY |
MONDAY = "Monday" |
Monday, numeric code 1. |
TUESDAY |
TUESDAY = "Tuesday" |
Tuesday, numeric code 2. |
WEDNESDAY |
WEDNESDAY = "Wednesday" |
Wednesday, numeric code 3. |
THURSDAY |
THURSDAY = "Thursday" |
Thursday, numeric code 4. |
FRIDAY |
FRIDAY = "Friday" |
Friday, numeric code 5. |
SATURDAY |
SATURDAY = "Saturday" |
Saturday, numeric code 6. |
std_time v1 · API Index · Task Index · Scope and Limitations · Verification
Calendar data current to the horizons on Versioning and Data Currency. Shanghai, Bombay and Singapore answer exactly through 2026.
MPL-2.0 · Copyright (c) 2026 Jesse Sanford · published on TradingView as The_Peaceful_Lizard
Start here
The model
- Core Concepts
- Civil and Exact Arithmetic
- Value Semantics
- Error Model
- Time Zones
- Exchange Calendars
- Trading Days and Day Counts
- Expiries
- Sessions
- Formatting and Parsing
- Choosing the Right Tool
- Pitfalls
Recipes
Reference
- API Index · Task Index
- DateTime
- Session
- Zone
- Exchange
- Period · Interval
- Weekday · Enums
- Free functions
- Glossary
The fine print