Time
provide.foundation.time
¶
TODO: Add module docstring.
Functions¶
provide_now
¶
Get current datetime with timezone awareness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
str | ZoneInfo | None
|
Timezone (string name, ZoneInfo object, or None for local) |
None
|
Returns:
| Type | Description |
|---|---|
datetime
|
Current datetime with timezone information |
Example
now = provide_now() now.tzinfo is not None True utc_now = provide_now("UTC") utc_now.tzinfo.key 'UTC'
Source code in provide/foundation/time/core.py
provide_sleep
¶
Sleep with Foundation tracking and interruption support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds
|
float
|
Number of seconds to sleep |
required |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If seconds is negative |
Example
provide_sleep(0.1) # Sleep for 100ms