Skip to main content

date-time-event

Codacy Badge Codacy Badge FOSSA Status HitCount

A very simple package to trigger events at a specific DateTime.

Installation

Use the package manager pip to install with the following command:

pip install date-time-event

If you would like to get the latest master or branch from github, you could also:

pip install git+https://github.com/Saadmairaj/date-time-event

Or even select a specific revision (branch/tag/commit):

pip install git+https://github.com/Saadmairaj/date-time-event@master

Usage

It is very simple and easy to use. First import the class which can be used either as a decorator or a thread function.

from date_time_event import Untiltime

The Untiltime class is threaded based timer which will wait till the given date or timer is met. As it runs on a separate thread, it doesn't effect the main thread or lock it.

from datetime import datetime, timedelta
from date_time_event import Untiltime

# Current datetime with 5 seconds in future.
date = datetime.now() + timedelta(0, 5)


@Untiltime(dateOrtime=date)
def function():
    print('Hello! Its time!', datetime.now())


function()
print('Function will be call at: %s \n' % date)
  • Untiltime decorator options. Syntax: @Untiltime( **options )

    Options Description
    function Pass Target function.
    dateOrtime Give date or time for the function to trigger if None give function will be a threaded function which can only run once. The date, time or datetime should be an instance of datetime module.
    name A string used for identification purposes only. Just like in thread
    join Wait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates.
    group Reserved for future extension when a ThreadGroup class is implemented.
    daemon A boolean value indicating whether this thread is a daemon thread (True) or not (False).
    args The args is the argument tuple for the target invocation. Defaults to ().
    kwargs The kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.

The Untiltime class can also be used as thread class. Like so

from datetime import datetime, timedelta
from date_time_event import Untiltime

def function():
    print('Hello! Its time!', datetime.now())


# Current datetime with 5 seconds in future.
date = datetime.now() + timedelta(0, 5)

th = Untiltime(function, dateOrtime=date)
th.start()

print('Function will be call at: %s \n' % date)

Once the thread is called it can be stopped or cancel if called .cancel() method before the datetime event occurs.

  • Set date can be changed with property date, if the thread has not started.
from datetime import datetime, timedelta
from date_time_event import Untiltime

def function():
    print('Hello! Its time!', datetime.now())


# Current datetime with 5 seconds in future.
date = datetime.now() + timedelta(0, 1)

th = Untiltime(function, dateOrtime=date)
# Initializing new date
th.date = datetime.now() + timedelta(0, 5)
th.start()

print('Function will be call at: %s \n' % th.date)

License

FOSSA Status

Metadata

Release files for date-time-event 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for date-time-event 0.0.1
File Size Uploaded Provenance
date-time-event-0.0.1.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for date-time-event 0.0.1
File Interpreter ABI Platform
date_time_event-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.7 kB

Release files / date-time-event-0.0.1.tar.gz

Download URL date-time-event-0.0.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d546e6e35230b180999e4aa83539e99414b4bab112409da5d0427a3f06b1883e
BLAKE2b-256 checksum
How to use checksums
3d2baa00c00b193888739a0b71896d85d29468217b2794f784e6f1607924a1a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / date_time_event-0.0.1-py3-none-any.whl

Download URL date_time_event-0.0.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e6e0fe70dac67d981368b0da41925672d88bfe19a6f2bdff91a2ca1cdafd09d
BLAKE2b-256 checksum
How to use checksums
a84f5d30798c8b705a280fba634e7772b05d54fc2cffdf93aaba1e362d439c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Security for date-time-event 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page