gnome.scripting.time_utils

Handy utilities for working with time

Internally, py_Gnome uses datetime.timedelta objects to represent time spans. But it is a bit awkward to create these objects:

datetime.timedelta(seconds=3600)

The time_utils module provides handy utilities to make it easier to construct these objects.

Examples:

hours() – represents one hour

hours(12) – represents 12 hours

As these functions return timedelta objects, you can do math with them:

seconds() * 60
days(2) + hours(12)

etc…

These are the full set:

seconds
minutes
hours
days
weeks

Attributes

now

Functions

seconds([seconds])

returns a datetime.timedelta object representing the specified number of seconds

minutes([minutes])

returns a datetime.timedelta object representing the specified number of minutes

hours([hours])

returns a datetime.timedelta object representing the specified number of hours

days([days])

returns a datetime.timedelta object representing the specified number of days

weeks([weeks])

Returns a datetime.timedelta object representing the specified number of weeks

Module Contents

gnome.scripting.time_utils.now
gnome.scripting.time_utils.seconds(seconds=1)

returns a datetime.timedelta object representing the specified number of seconds

Parameters:

seconds (int or float) – number of seconds – defaults to 1 second.

gnome.scripting.time_utils.minutes(minutes=1)

returns a datetime.timedelta object representing the specified number of minutes

Parameters:

minutes (int or float) – number of minutes – defaults to 1 day.

gnome.scripting.time_utils.hours(hours=1)

returns a datetime.timedelta object representing the specified number of hours

Parameters:

hours (int or float) – number of hours – defaults to 1 hour.

gnome.scripting.time_utils.days(days=1)

returns a datetime.timedelta object representing the specified number of days

Parameters:

days (int or float) – number of days – defaults to 1 day.

gnome.scripting.time_utils.weeks(weeks=1)

Returns a datetime.timedelta object representing the specified number of weeks

Parameters:

weeks (int or float) – number of weeks – defaults to 1 week.