date_sys¶
shortfx.fxDate.date_sys
¶
System date and time operations module.
This module provides functions to retrieve current system date and time information, including current datetime, date, time, year, month, day, weekday, and timezone-aware operations. All 'current_*' functions return information based on the system's local time.
Functions¶
current_date() -> datetime
¶
Gets the current local date (without the time component).
Description
Returns a datetime object representing only the current date with time components (hour, minute, second, microsecond) set to zero.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A datetime object representing the current local date at midnight. |
Usage Example
from shortfx.fxDate.date_sys import current_date today = current_date() print(today.strftime('%Y-%m-%d')) # Output varies 2026-01-03 print(today.strftime('%Y-%m-%d %H:%M:%S')) 2026-01-03 00:00:00
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_datetime() -> datetime
¶
Gets the current local date and time.
Description
Returns the current date and time according to the system's local timezone. The returned datetime object is timezone-naive.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A datetime object representing the current local date and time. |
Usage Example
from shortfx.fxDate.date_sys import current_datetime now = current_datetime() print(now.strftime('%Y-%m-%d %H:%M:%S')) # Output varies 2026-01-03 14:30:45
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_day() -> int
¶
Gets the current day of the month (1-31).
Description
Returns the day component from the current system date as a number from 1 to 31 (depending on the month).
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The current day of the month as an integer. |
Usage Example
from shortfx.fxDate.date_sys import current_day day = current_day() print(day) # Output varies 3
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_days_in_month() -> int
¶
Returns the number of days in the current month.
Description
Delegates to date_operations.days_in_month using the current
year and month.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of days in the current month (28-31). |
Example
from shortfx.fxDate.date_sys import current_days_in_month current_days_in_month() # For April 2026 30
Complexity: O(1)
Source code in shortfx/fxDate/date_sys.py
current_first_day_of_month() -> datetime
¶
Returns the first day of the current month at midnight.
Description
Delegates to date_operations.start_of_month using today's date.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
First day of the current month at 00:00:00. |
Example
from shortfx.fxDate.date_sys import current_first_day_of_month current_first_day_of_month() # For March 2026 datetime.datetime(2026, 3, 1, 0, 0)
Complexity: O(1)
Source code in shortfx/fxDate/date_sys.py
current_is_leap_year() -> bool
¶
Checks if the current year is a leap year.
Description
Delegates to date_operations.is_leap_year using the current year.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the current year is a leap year, False otherwise. |
Example
from shortfx.fxDate.date_sys import current_is_leap_year current_is_leap_year() # For 2026 False
Complexity: O(1)
Source code in shortfx/fxDate/date_sys.py
current_is_weekend() -> bool
¶
Checks if the current date is a weekend (Saturday or Sunday).
Description
Returns True if today is Saturday or Sunday, False if it's a weekday. Delegates to date_operations.is_weekend().
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if current date is Saturday or Sunday, False otherwise. |
Usage Example
from shortfx.fxDate.date_sys import current_is_weekend current_is_weekend() # For Friday 2026-01-03 False
For Saturday 2026-01-04¶
True
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_is_working_day() -> bool
¶
Checks if the current date is a working day (Monday to Friday).
Description
Returns True if today is a weekday (Monday through Friday), False if it's a weekend (Saturday or Sunday). Does not consider holidays. Delegates to date_operations.is_working_day().
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if current date is Monday-Friday, False otherwise. |
Usage Example
from shortfx.fxDate.date_sys import current_is_working_day current_is_working_day() # For Friday 2026-01-03 True
For Saturday 2026-01-04¶
False
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_last_day_of_month() -> datetime
¶
Gets the last day of the current month.
Description
Returns a datetime object representing the last calendar day of the current month at midnight. Delegates to date_operations.last_day_of_month().
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A datetime object for the last day of the current month. |
Usage Example
from shortfx.fxDate.date_sys import current_last_day_of_month last_day = current_last_day_of_month() # If current month is January 2026 print(last_day.strftime('%Y-%m-%d')) 2026-01-31
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_last_friday_of_month() -> datetime
¶
Gets the last Friday of the current month.
Description
Returns a datetime object representing the last Friday occurring in the current month. Delegates to date_operations.last_weekday_of_month().
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A datetime object for the last Friday of the current month. |
Usage Example
from shortfx.fxDate.date_sys import current_last_friday_of_month last_fri = current_last_friday_of_month() # For January 2026 print(last_fri.strftime('%Y-%m-%d %A')) 2026-01-30 Friday
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_month() -> int
¶
Gets the current month (1-12).
Description
Returns the month component from the current system date as a number from 1 (January) to 12 (December).
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The current month as an integer (1 for January, 12 for December). |
Usage Example
from shortfx.fxDate.date_sys import current_month month = current_month() print(month) # Output varies 1
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_month_name(language: str = 'en') -> str
¶
Returns the name of the current month in the specified language.
Description
Delegates to date_operations.month_name using today's date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language
|
str
|
Two-letter ISO 639-1 language code. Defaults to |
'en'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Full month name (e.g. |
Example
from shortfx.fxDate.date_sys import current_month_name current_month_name('en') # For January 'January'
Complexity: O(1)
Source code in shortfx/fxDate/date_sys.py
current_next_friday() -> datetime
¶
Gets the next Friday after the current date.
Description
Returns a datetime object representing the next Friday that occurs after today. If today is Friday, returns next week's Friday. Delegates to date_operations.next_weekday().
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A datetime object for the next Friday after today. |
Usage Example
from shortfx.fxDate.date_sys import current_next_friday next_fri = current_next_friday() # If today is Friday 2026-01-03 print(next_fri.strftime('%Y-%m-%d %A')) 2026-01-10 Friday
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_previous_friday() -> datetime
¶
Gets the previous Friday before the current date.
Description
Returns a datetime object representing the most recent Friday that occurred before today. If today is Friday, returns last week's Friday. Delegates to date_operations.previous_weekday().
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A datetime object for the previous Friday before today. |
Usage Example
from shortfx.fxDate.date_sys import current_previous_friday prev_fri = current_previous_friday() # If today is Friday 2026-01-03 print(prev_fri.strftime('%Y-%m-%d %A')) 2025-12-27 Friday
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_quarter() -> int
¶
Returns the current quarter of the year (1-4).
Description
Delegates to date_operations.get_quarter using today's date.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Quarter number (1 for Jan-Mar, 4 for Oct-Dec). |
Example
from shortfx.fxDate.date_sys import current_quarter current_quarter() # For March 2026 1
Complexity: O(1)
Source code in shortfx/fxDate/date_sys.py
current_season(hemisphere: str = 'northern', lang: str = 'en') -> str
¶
Returns the current season of the year.
Description
Delegates to date_operations.get_season using today's date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hemisphere
|
str
|
|
'northern'
|
lang
|
str
|
Two-letter ISO 639-1 language code. Defaults to |
'en'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Season name (e.g. |
Example
from shortfx.fxDate.date_sys import current_season current_season('northern', 'en') # For April 2026 'Spring'
Complexity: O(1)
Source code in shortfx/fxDate/date_sys.py
current_time() -> datetime
¶
Gets the current local time (without the date component).
Description
Returns a datetime object with the current time but using a minimal date (datetime.min.date()). Useful for time-only comparisons.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A datetime object with current time and minimal date (0001-01-01). |
Usage Example
from shortfx.fxDate.date_sys import current_time time_now = current_time() print(time_now.strftime('%H:%M:%S')) # Output varies 14:30:45 print(time_now.strftime('%Y-%m-%d %H:%M:%S')) 0001-01-01 14:30:45
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_week_number() -> int
¶
Returns the current ISO week number (1-53).
Description
Delegates to datetime.isocalendar for the current date.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
ISO 8601 week number. |
Example
from shortfx.fxDate.date_sys import current_week_number current_week_number() # For 2026-01-05 2
Complexity: O(1)
Source code in shortfx/fxDate/date_sys.py
current_weekday_name(language: str = 'en') -> str
¶
Gets the current weekday name for the current date.
Description
Returns the name of the current weekday in the specified language. Delegates to date_operations.weekday_name() for name resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language
|
str
|
Language code for the weekday name. Supports 'en' (English) and 'es' (Spanish). Defaults to 'en'. |
'en'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the current day of the week. |
Usage Example
from shortfx.fxDate.date_sys import current_weekday_name current_weekday_name('en') # For Friday 'Friday' current_weekday_name('es') # For Friday 'Viernes'
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_weekday_number(start_day: str = 'european') -> int
¶
Retrieves the current day of the week as a number.
Description
Returns the current weekday as an integer, supporting both European (Monday=0) and US (Sunday=0) conventions. Uses datetime.weekday() as the base and adjusts for US convention when requested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_day
|
str
|
Week start convention. Accepted values: 'european' (Monday=0, ..., Sunday=6) or 'us' (Sunday=0, Monday=1, ..., Saturday=6). Defaults to 'european'. |
'european'
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The current day of the week as an integer (0-6). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If 'start_day' is not 'european' or 'us'. |
Usage Example
from shortfx.fxDate.date_sys import current_weekday_number current_weekday_number(start_day='european') # For Friday 4 current_weekday_number(start_day='us') # For Friday 5
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
current_year() -> int
¶
Gets the current year.
Description
Returns the year component from the current system date.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The current year as a four-digit integer. |
Usage Example
from shortfx.fxDate.date_sys import current_year year = current_year() print(year) # Output varies 2026
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
get_local_now(tz: Optional[str] = None) -> datetime
¶
Gets the current date and time in a specified timezone.
Description
Returns a timezone-aware datetime object representing the current time in the specified timezone. If no timezone is specified, returns the current time in the system's local timezone. Timezone names must follow the IANA timezone database format (e.g., 'America/New_York', 'Europe/Madrid').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
Optional[str]
|
IANA timezone name (e.g., 'America/New_York'). If None, uses the system's local timezone. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
A timezone-aware datetime object in the specified timezone. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If 'tz' is not a string when provided. |
ValueError
|
If 'tz' is not a valid IANA timezone name. |
Usage Example
from shortfx.fxDate.date_sys import get_local_now tokyo_now = get_local_now('Asia/Tokyo') print(tokyo_now.strftime('%Y-%m-%d %H:%M:%S %Z%z')) 2026-01-03 23:30:45 JST+0900
local_now = get_local_now() print(local_now.strftime('%Y-%m-%d %H:%M:%S %Z%z')) 2026-01-03 15:30:45 CET+0100
ny_now = get_local_now('America/New_York') print(ny_now.strftime('%Y-%m-%d %H:%M:%S %Z%z')) 2026-01-03 09:30:45 EST-0500
Cost: O(1)
Source code in shortfx/fxDate/date_sys.py
seconds_since_midnight() -> float
¶
Returns the number of seconds elapsed since midnight of the current day.
Description
Equivalent to VBA's Timer function. Useful for benchmarking, daily scheduling offsets, or computing elapsed durations within a day.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Seconds (with fractional microseconds) since 00:00:00 today. |
Example
from shortfx.fxDate.date_sys import seconds_since_midnight secs = seconds_since_midnight() 0 <= secs < 86400 True
Complexity: O(1)