sc4py.datetime module
- sc4py.datetime.daterange(start: date, end: date, step: timedelta = datetime.timedelta(days=1)) Generator[date, None, None][source]
Generates a range of dates from start to end (inclusive).
- Parameters:
start (date) – The start date.
end (date) – The end date.
step (timedelta) – The difference between each date in the range.
- Yields:
date – The next date in the range.
- Example::
>>> from datetime import date, timedelta >>> list(daterange(date(2026, 4, 1), date(2026, 4, 3))) [datetime.date(2026, 4, 1), datetime.date(2026, 4, 2), datetime.date(2026, 4, 3)] >>> list(daterange(date(2026, 4, 1), date(2026, 4, 5), step=timedelta(days=2))) [datetime.date(2026, 4, 1), datetime.date(2026, 4, 3), datetime.date(2026, 4, 5)]
- sc4py.datetime.now(tz=None)
Returns new datetime object representing current time local to tz.
- tz
Timezone object.
If no tz is specified, uses local timezone.
- sc4py.datetime.now_str() str[source]
Returns the current date and time as a formatted string.
- Returns:
The current date and time in the format “DD-MM-YYYY HH:MM:SS”.
- Return type:
str
- Example::
>>> now_str() '23-04-2026 14:30:00'
- sc4py.datetime.others_months() list[int][source]
Returns a list of all months except the current one.
- Returns:
A list of integers (1-12) excluding the current month.
- Return type:
list[int]
- Example::
>>> others_months() [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12]
- sc4py.datetime.this_month() int[source]
Returns the current month as an integer.
- Returns:
The current month (1-12).
- Return type:
int
- Example::
>>> this_month() 4
- sc4py.datetime.this_year() int[source]
Returns the current year as an integer.
- Returns:
The current year.
- Return type:
int
- Example::
>>> this_year() 2026
- sc4py.datetime.today()
Current date or datetime: same as self.__class__.fromtimestamp(time.time()).