TimePlugin Class
TimePlugin provides a set of functions to get the current time and date.
Usage: kernel.add_plugin(TimePlugin(), plugin_name="time")
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Constructor
TimePlugin()
Examples
{{time.date}} => Sunday, 12 January, 2031 {{time.today}} => Sunday, 12 January, 2031 {{time.iso_date}} => 2031-01-12 {{time.now}} => Sunday, January 12, 2031 9:15 PM {{time.utcNow}} => Sunday, January 13, 2031 5:15 AM {{time.time}} => 09:15:07 PM {{time.year}} => 2031 {{time.month}} => January {{time.monthNumber}} => 01 {{time.day}} => 12 {{time.dayOfWeek}} => Sunday {{time.hour}} => 9 PM {{time.hourNumber}} => 21 {{time.days_ago $days}} => Sunday, 7 May, 2023 {{time.last_matching_day $dayName}} => Sunday, 7 May, 2023 {{time.minute}} => 15 {{time.minutes}} => 15 {{time.second}} => 7 {{time.seconds}} => 7 {{time.timeZoneOffset}} => -0800 {{time.timeZoneName}} => PST
Methods
| date |
Get the current date. |
| date_matching_last_day_name |
Get the date of the last day matching the supplied day name. |
| day |
Get the current day of the month. |
| day_of_week |
Get the current day of the week. |
| days_ago |
Get the date a provided number of days in the past. |
| hour |
Get the current hour. |
| hour_number |
Get the current hour number. |
| iso_date |
Get the current date in iso format. |
| minute |
Get the current minute. |
| month |
Get the current month. |
| month_number |
Get the current month number. |
| now |
Get the current date and time in the local time zone. |
| second |
Get the seconds on the current minute. |
| time |
Get the current time in the local time zone. |
| time_zone_name |
Get the current time zone name. |
| time_zone_offset |
Get the current time zone offset. |
| today |
Get the current date. |
| utc_now |
Get the current date and time in UTC. |
| year |
Get the current year. |
date
Get the current date.
date() -> str
Examples
{{time.date}} => Sunday, 12 January, 2031
date_matching_last_day_name
Get the date of the last day matching the supplied day name.
date_matching_last_day_name(day_name: str) -> str
Parameters
| Name | Description |
|---|---|
|
day_name
Required
|
The day name to match with. |
Returns
| Type | Description |
|---|---|
|
The date of the matching day. |
Examples
{{time.date_matching_last_day_name $input}} => Sunday, 7 May, 2023
day
Get the current day of the month.
day() -> str
Examples
{{time.day}} => 12
day_of_week
Get the current day of the week.
day_of_week() -> str
Examples
{{time.dayOfWeek}} => Sunday
days_ago
Get the date a provided number of days in the past.
days_ago(days: str) -> str
Parameters
| Name | Description |
|---|---|
|
days
Required
|
The number of days to offset from today |
Returns
| Type | Description |
|---|---|
|
The date of the offset day. |
Examples
{{time.days_ago $input}} => Sunday, 7 May, 2023
hour
Get the current hour.
hour() -> str
Examples
{{time.hour}} => 9 PM
hour_number
Get the current hour number.
hour_number() -> str
Examples
{{time.hourNumber}} => 21
iso_date
Get the current date in iso format.
iso_date() -> str
Examples
{{time.iso_date}} => 2031-01-12
minute
Get the current minute.
minute() -> str
Examples
{{time.minute}} => 15
month
Get the current month.
month() -> str
Examples
{{time.month}} => January
month_number
Get the current month number.
month_number() -> str
Examples
{{time.monthNumber}} => 01
now
Get the current date and time in the local time zone.
now() -> str
Examples
{{time.now}} => Sunday, January 12, 2031 9:15 PM
second
Get the seconds on the current minute.
second() -> str
Examples
{{time.second}} => 7
time
Get the current time in the local time zone.
time() -> str
Examples
{{time.time}} => 09:15:07 PM
time_zone_name
Get the current time zone name.
time_zone_name() -> str
Examples
{{time.timeZoneName}} => PST
time_zone_offset
Get the current time zone offset.
time_zone_offset() -> str
Examples
{{time.timeZoneOffset}} => -08:00
today
Get the current date.
today() -> str
Examples
{{time.today}} => Sunday, 12 January, 2031
utc_now
Get the current date and time in UTC.
utc_now() -> str
Examples
{{time.utcNow}} => Sunday, January 13, 2031 5:15 AM
year
Get the current year.
year() -> str
Examples
{{time.year}} => 2031