Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

date-offset

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-offset

An library to allow offset of dates by a string

  • 0.0.3
  • PyPI
  • Socket score

Maintainers
1

Date-offset

.. image:: https://badge.fury.io/py/date-offset.svg :target: http://badge.fury.io/py/date-offset

.. image:: https://codecov.io/gh/django-advance-utils/date-offset/branch/main/graph/badge.svg?token=QPGW5TIGX3 :target: https://codecov.io/gh/django-advance-utils/date-offset

This allow you to offset date / time with a string.

Example

.. code-block::

d = DateOffset()
tomorrow = d.get_offset("1d")
yesterday = d.get_offset("-1d")

Keyword

  • start of week (Monday)

  • * end of week
  • % first day of the month
  • d offset by days (1d)
  • w offset by weeks (1w)
  • m offset by months (1m)
  • y offset by years (1y)
  • ~ not weekend
  • s offset by seconds (3600s)
  • i offset by minutes (60m)
  • h offset by hours (1h)
  • t time (10t = 10hr. 10:15t = 10hr 15mins. 10:15:45t = 10hr 15mins 45secs)

Usage

If you want to include time in your output the include_time must be set.

.. code-block::

d = DateOffset()
one_hours_time = d.get_offset("1h", include_time=True)

Nested string can be used

.. code-block::

d = DateOffset()
second_day_of_current_month = d.get_offset("%1d")

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc