Giter Site home page Giter Site logo

datedelta's Introduction

DateDelta

Tests Docs

A command line tool for computing the number of days between two dates.

alt text

Getting Started

Read the documentation: https://datedelta.readthedocs.io.

Requirements

  • Python >=3.9

DateDelta is written in pure python with no additional package dependencies.

Installation

The project can be installed directly from github.

$ pip install git+https://github.com/keeeal/datedelta.git

Usage

Command Line Interface

DateDelta is a command line tool which accepts two date string arguments. The program will compute the number of days between the two dates provided, print the result, and exit.

The date strings must be provided in isoformat, specifically in the form YYYY-MM-DD.

usage: datedelta [-h] [-i] [date_strings ...]

positional arguments:
  date_strings

optional arguments:
  -h, --help         show this help message and exit
  -i, --interactive

For example:

$ datedelta 2012-01-10 2012-01-11
0
$ datedelta 2021-12-01 2017-12-14
1447

Interactive Mode

DateDelta can be started in interactive mode using the -i flag.

In interactive mode, pairs of dates can be provided on the same line and the difference will be displayed. Type exit to close the interactive session.

For example:

$ datedelta -i
2012-01-10 2012-01-11
0
2021-12-01 2017-12-14
1447
exit

Incomplete or malformed input during interactive mode will result in an error message and the program will exit.

Python Package

DateDelta can be used as a Python package. At the core of DateDelta is the Date class.

from datedelta import Date

Date classes can be initialized directly in the same way as Python's built-in datetime.date class.

Date(2012, 1, 10) - Date(2012, 1, 11)  # => 0
Date(2021, 12, 1) - Date(2017, 12, 14)  # => 1447

For more details, the API can be found here.

datedelta's People

Watchers

James Keal avatar

datedelta's Issues

Type checking in Date

Date should check the type of day, month, and year when checking validity.

AC:
ValueError raised when non-int arguments provided to Date initializer.

Depreciation warnings in pipeline

Under the "Test with tox" stage, setuptools complains that various fields are being used in setup.cfg when they should be used in pyproject.toml.

For example:

    ##########################################################################
    # configuration would be ignored/result in error due to `pyproject.toml` #
    ##########################################################################

    The following seems to be defined outside of `pyproject.toml`:

    `license = 'MIT'`

    According to the spec (see the link below), however, setuptools CANNOT
    consider this value unless 'license' is listed as `dynamic`.

    https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

    For the time being, `setuptools` will still consider the given value (as a
    **transitional** measure), but please note that future releases of setuptools will
    follow strictly the standard.

    To prevent this warning, you can list 'license' under `dynamic` or alternatively
    remove the `[project]` table from your file and rely entirely on other means of
    configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.