sciris.sc_datetime

Time/date utilities.

Highlights:

Functions

date

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

datedelta

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

daterange

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

datetoyear

Convert a DateTime instance to decimal year.

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.

elapsedtimestr

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

getdate

Alias for converting a date object to a formatted string.

now

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

randsleep

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

readdate

Convenience function for loading a date from a string.

tic

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

timedsleep

Delay for a certain amount of time, to ensure accurate timing.

toc

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

toctic

A convenience fu`ction for multiple timings.

Classes

Timer

alias of timer

timer

Simple timer class.