sc_datetime#

Time/date utilities.

Highlights:

Classes

timer

Simple timer class.

Timer

alias of timer

Functions

time

Get current time in seconds -- alias to time.time()

now

Get the current time as a datetime object, optionally in UTC time.

getdate

Alias for converting a date object to a formatted string.

readdate

Convenience function for loading a date from a string.

date

Convert any reasonable object -- a string, integer, or datetime object, or list/array of any of those -- to a date object (or string, pandas, or numpy date).

day

Convert a string, date/datetime object, or int to a day (int), the number of days since the start day.

daydiff

Convenience function to find the difference between two or more days.

daterange

Return a list of dates from the start date to the end date.

datedelta

Perform calculations on a date string (or date object), returning a string (or a date).

datetoyear

Convert a DateTime instance to decimal year.

tic

With sc.toc(), a little pair of functions to calculate a time difference:

toc

With sc.tic(), a little pair of functions to calculate a time difference.

toctic

A convenience fuction for multiple timings.

elapsedtimestr

Accepts a datetime object or a string in ISO 8601 format and returns a human-readable string explaining when this time was.

timedsleep

Pause for the specified amount of time, taking into account how long other operations take.

randsleep

Sleep for a nondeterminate period of time (useful for desynchronizing tasks)