chronocalc


Namechronocalc JSON
Version 0.9.1 PyPI version JSON
download
home_page
Summarychronocalc - a date/time/duration calculator
upload_time2023-07-26 18:50:25
maintainer
docs_urlNone
author
requires_python>=3
license
keywords calculator compute date datetime duration evaluate repl time
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            chronocalc
==========

chronocalc is a basic calculator for time and durations. It can:

* add durations::

	> 1 day + 1445 minutes
	2 days, 5 minutes

* subtract durations::

	> 1 hour, 5 minutes - 555 seconds
	55 minutes, 45 seconds

* multiply/divide durations::

	> 40 mins * 4
	2 hours, 40 minutes
	> 1 day / 2
	12 hours

* add durations to dates::

	> 2015/07/08 + 3 weeks
	2015-07-29 00:00:00

* subtract durations from dates::

	> 2015/07/08 11pm - 15 hours
	2015-07-08 08:00:00

* compute duration between two dates::

	> 2015/07/08 - 2015/07/06 12pm
	1 day, 12 hours

* compute the ratio of two durations::

	> 1 day / 1 minute
	1440.0

* do all of the above at once::

	> 2 * ((100 days + 2015/07/08) - (2015/07/01 - 48 hours))
	7 months, 1 week, 5 days

Invocation
----------

If given an argument, chronocalc will eval it and exit, else, it will start a REPL (Read-Eval-Print Loop) prompt to eval multiple expressions.

Input format
------------

Grammar
+++++++

In EBNF format::

	digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
	number ::= [ "-" ], digit, {digit}, [ ".", {digit} ];

	unit ::= "milliseconds" | "millisecond" | "ms" 
	       | "seconds" | "second" | "sec" | "secs" | "s"
	       | "minutes" | "minutes" | "mins" | "min"
	       | "hours" | "hour" | "hrs" | "hr"
	       | "days" | "day" | "d"
	       | "weeks" | "week" | "wks" | "wk" | "w"
	       | "months" | "month" | "mons" | "mon"
	       | "years" | "year" | "yrs" | "yr" | "y";

	duration ::= number, unit, { ",", number, unit };

	iso8601d ::= digit, digit, digit, digit, "-", digit, digit, "-", digit, digit (* YYYY-MM-DD *)
		   | digit, digit, digit, digit, "-", digit, digit, digit (* YYYY-DDD day in year *)
		   | digit, digit, digit, digit, "-W", digit, digit, "-", digit (* YYYY-Www-D week in year, day in week *)
		   | digit, digit, digit, digit, digit, digit, digit, digit (* YYYYMMDD *)
		   | digit, digit, digit, digit, digit, digit, digit (* YYYYDDD day in year *)
		   | digit, digit, digit, digit, digit, digit, digit (* YYYYwwD week in year, day in week *);
	iso8601t ::= "digit, digit, ":", digit, digit, [ ":", digit, digit ] (* HH:MM:SS *)
		   | "digit, digit, digit, digit, [ digit, digit ] (* HHMMSS *);
	iso8601 ::= iso8601d, [ ( "T" | ?whitespace? ), iso8601t ];

	date ::= digit, digit, digit, digit, ( "/" | "-" ), digit, [ digit ], ( "/", "-" ), digit, [ digit ];
	time ::= digit, [ digit ], ( "am" | "pm" )
	       | digit, [ digit ], ":", digit, [ digit ], [ ":", digit, [ digit ] ], [ "am" | "pm" ];

	datetime ::= date, [ time ] | [ date ], time | iso8601;

	factor ::= duration | datetime | number | "(", expression, ")";
	term ::= term, [ ( "*" | "/" ), factor ];
	expression ::= expression, [ ( "+" | "-" ), term ];

Examples
++++++++

These are example of the datetimes and durations formats accepted by chronocalc::

	now
	today
	epoch
	2015-01-01 01:23
	2015-01-01 12:34:56
	20150101T123456
	2015/01/01
	2015/01/01 13:34
	2015/01/01 1:34pm
	12:34
	3am
	1 day
	1y, 3w, 4hrs, 5s
	1 year, 2 months, 3 days, 4 weeks, 5 hours, 6 minutes, 7 seconds, 8 milliseconds

FAQ
---

* Q: Are timezones handled?
* A: Not yet. Using them will return a syntax error.

* Q: Are leap seconds handled?
* A: Not at all, and probably won't be. "2015/07/01 - 2015/06/30 23:59:59" returns "1 second".

* Q: Is the format YYYY/MM/DD or YYYY/DD/MM?
* A: YYYY/MM/DD.

* Q: When inputting date "20150101", it is parsed as number "20150101".
* A: That's not a question, and that's effectively a number. To force a datetime form, use "20150101 00:00" instead.

Dependencies
------------

chronocalc depends on `relativedelta <https://dateutil.readthedocs.io/en/stable/relativedelta.html>`_ for computing durations.

License
-------

chronocalc is licensed under the `WTFPLv2 <http://wtfpl.net>`_. See COPYING.WTFPL file.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "chronocalc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "calculator,compute,date,datetime,duration,evaluate,repl,time",
    "author": "",
    "author_email": "Hg <dev@indigo.re>",
    "download_url": "https://files.pythonhosted.org/packages/7e/88/24353606051a0561053ab6d18b7d079e7aa0ef9fc559da2260fa8939064d/chronocalc-0.9.1.tar.gz",
    "platform": null,
    "description": "chronocalc\n==========\n\nchronocalc is a basic calculator for time and durations. It can:\n\n* add durations::\n\n\t> 1 day + 1445 minutes\n\t2 days, 5 minutes\n\n* subtract durations::\n\n\t> 1 hour, 5 minutes - 555 seconds\n\t55 minutes, 45 seconds\n\n* multiply/divide durations::\n\n\t> 40 mins * 4\n\t2 hours, 40 minutes\n\t> 1 day / 2\n\t12 hours\n\n* add durations to dates::\n\n\t> 2015/07/08 + 3 weeks\n\t2015-07-29 00:00:00\n\n* subtract durations from dates::\n\n\t> 2015/07/08 11pm - 15 hours\n\t2015-07-08 08:00:00\n\n* compute duration between two dates::\n\n\t> 2015/07/08 - 2015/07/06 12pm\n\t1 day, 12 hours\n\n* compute the ratio of two durations::\n\n\t> 1 day / 1 minute\n\t1440.0\n\n* do all of the above at once::\n\n\t> 2 * ((100 days + 2015/07/08) - (2015/07/01 - 48 hours))\n\t7 months, 1 week, 5 days\n\nInvocation\n----------\n\nIf given an argument, chronocalc will eval it and exit, else, it will start a REPL (Read-Eval-Print Loop) prompt to eval multiple expressions.\n\nInput format\n------------\n\nGrammar\n+++++++\n\nIn EBNF format::\n\n\tdigit ::= \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\";\n\tnumber ::= [ \"-\" ], digit, {digit}, [ \".\", {digit} ];\n\n\tunit ::= \"milliseconds\" | \"millisecond\" | \"ms\" \n\t       | \"seconds\" | \"second\" | \"sec\" | \"secs\" | \"s\"\n\t       | \"minutes\" | \"minutes\" | \"mins\" | \"min\"\n\t       | \"hours\" | \"hour\" | \"hrs\" | \"hr\"\n\t       | \"days\" | \"day\" | \"d\"\n\t       | \"weeks\" | \"week\" | \"wks\" | \"wk\" | \"w\"\n\t       | \"months\" | \"month\" | \"mons\" | \"mon\"\n\t       | \"years\" | \"year\" | \"yrs\" | \"yr\" | \"y\";\n\n\tduration ::= number, unit, { \",\", number, unit };\n\n\tiso8601d ::= digit, digit, digit, digit, \"-\", digit, digit, \"-\", digit, digit (* YYYY-MM-DD *)\n\t\t   | digit, digit, digit, digit, \"-\", digit, digit, digit (* YYYY-DDD day in year *)\n\t\t   | digit, digit, digit, digit, \"-W\", digit, digit, \"-\", digit (* YYYY-Www-D week in year, day in week *)\n\t\t   | digit, digit, digit, digit, digit, digit, digit, digit (* YYYYMMDD *)\n\t\t   | digit, digit, digit, digit, digit, digit, digit (* YYYYDDD day in year *)\n\t\t   | digit, digit, digit, digit, digit, digit, digit (* YYYYwwD week in year, day in week *);\n\tiso8601t ::= \"digit, digit, \":\", digit, digit, [ \":\", digit, digit ] (* HH:MM:SS *)\n\t\t   | \"digit, digit, digit, digit, [ digit, digit ] (* HHMMSS *);\n\tiso8601 ::= iso8601d, [ ( \"T\" | ?whitespace? ), iso8601t ];\n\n\tdate ::= digit, digit, digit, digit, ( \"/\" | \"-\" ), digit, [ digit ], ( \"/\", \"-\" ), digit, [ digit ];\n\ttime ::= digit, [ digit ], ( \"am\" | \"pm\" )\n\t       | digit, [ digit ], \":\", digit, [ digit ], [ \":\", digit, [ digit ] ], [ \"am\" | \"pm\" ];\n\n\tdatetime ::= date, [ time ] | [ date ], time | iso8601;\n\n\tfactor ::= duration | datetime | number | \"(\", expression, \")\";\n\tterm ::= term, [ ( \"*\" | \"/\" ), factor ];\n\texpression ::= expression, [ ( \"+\" | \"-\" ), term ];\n\nExamples\n++++++++\n\nThese are example of the datetimes and durations formats accepted by chronocalc::\n\n\tnow\n\ttoday\n\tepoch\n\t2015-01-01 01:23\n\t2015-01-01 12:34:56\n\t20150101T123456\n\t2015/01/01\n\t2015/01/01 13:34\n\t2015/01/01 1:34pm\n\t12:34\n\t3am\n\t1 day\n\t1y, 3w, 4hrs, 5s\n\t1 year, 2 months, 3 days, 4 weeks, 5 hours, 6 minutes, 7 seconds, 8 milliseconds\n\nFAQ\n---\n\n* Q: Are timezones handled?\n* A: Not yet. Using them will return a syntax error.\n\n* Q: Are leap seconds handled?\n* A: Not at all, and probably won't be. \"2015/07/01 - 2015/06/30 23:59:59\" returns \"1 second\".\n\n* Q: Is the format YYYY/MM/DD or YYYY/DD/MM?\n* A: YYYY/MM/DD.\n\n* Q: When inputting date \"20150101\", it is parsed as number \"20150101\".\n* A: That's not a question, and that's effectively a number. To force a datetime form, use \"20150101 00:00\" instead.\n\nDependencies\n------------\n\nchronocalc depends on `relativedelta <https://dateutil.readthedocs.io/en/stable/relativedelta.html>`_ for computing durations.\n\nLicense\n-------\n\nchronocalc is licensed under the `WTFPLv2 <http://wtfpl.net>`_. See COPYING.WTFPL file.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "chronocalc - a date/time/duration calculator",
    "version": "0.9.1",
    "project_urls": {
        "Homepage": "https://gitlab.com/hydrargyrum/timecalc"
    },
    "split_keywords": [
        "calculator",
        "compute",
        "date",
        "datetime",
        "duration",
        "evaluate",
        "repl",
        "time"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2833d7c1da0be11ea6c3340749628ce9c8b7a5eb82ec14c63c9ead0b7eb132d7",
                "md5": "4be01e1b73fec157f25f0174557642a7",
                "sha256": "b78c559576cfddf9da6dfb8c9f485a2aaf5c6f66742c8effc6dd1e2443d726a6"
            },
            "downloads": -1,
            "filename": "chronocalc-0.9.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4be01e1b73fec157f25f0174557642a7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 10076,
            "upload_time": "2023-07-26T18:50:24",
            "upload_time_iso_8601": "2023-07-26T18:50:24.329236Z",
            "url": "https://files.pythonhosted.org/packages/28/33/d7c1da0be11ea6c3340749628ce9c8b7a5eb82ec14c63c9ead0b7eb132d7/chronocalc-0.9.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e8824353606051a0561053ab6d18b7d079e7aa0ef9fc559da2260fa8939064d",
                "md5": "d3d92ae9fa95a32c34dfd6ab346ade8e",
                "sha256": "9050fc03f371713d43f57837473cafae43d91187ccb9a491fb82fc0e23b7fb7f"
            },
            "downloads": -1,
            "filename": "chronocalc-0.9.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d3d92ae9fa95a32c34dfd6ab346ade8e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 7526,
            "upload_time": "2023-07-26T18:50:25",
            "upload_time_iso_8601": "2023-07-26T18:50:25.990177Z",
            "url": "https://files.pythonhosted.org/packages/7e/88/24353606051a0561053ab6d18b7d079e7aa0ef9fc559da2260fa8939064d/chronocalc-0.9.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 18:50:25",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "hydrargyrum",
    "gitlab_project": "timecalc",
    "lcname": "chronocalc"
}
        
Elapsed time: 0.09537s