justdays


Namejustdays JSON
Version 1.8.4 PyPI version JSON
download
home_page
SummaryMakes working with days super easy
upload_time2023-01-02 14:03:33
maintainer
docs_urlNone
author
requires_python>=3.7
licenseThis is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to <https://unlicense.org>
keywords days adding days difference between days range of days last monday
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Justdays

Package to make working with days and ranges of days in Python super easy.

The package contains two classes: \
**Day** handles everything you want to do with days. \
**Period** handles a range of Day objects.

Current version: 1.8.4

## Installation
~~~~bash
python -m pip install justdays
~~~~

## Day class usage

### Initializing a Day
~~~~python
day = Day()  # No arguments, initalize with the current day
day = Day('2022-08-16')  # One argument, string in YYYY-MM-DD format
day = Day(2022, 32)  # Two arguments: year, week. Day with be the Monday of that week
day = Day(2022, 8, 16)  # Three arguments: year, month, day. 
day = Day(datetime(2022, 8, 16))  # Initialize with Python datetime object
day = Day(date(2022, 8, 16))  # Initialize with Python date object
~~~~

### Accessing Day fields
~~~~python
d = day.d  # int
m = day.m  # int
y = day.y  # int
as_string = day.str  # in YYYY-MM-DD format
~~~~

### Represenation
~~~~python
str(day) # Returns the day in YYYY-MM-DD format
day.as_datetime() # Returns the day as a Python datetime object
day.as_date() # Returns the day as a Python date object
day.strftime(format_string) # Returns the day as a string formatted according to the format string
day.as_unix_timestamp() # Returns the day as a unix timestamp (int)
~~~~

### Days further away or in the past
~~~~python
day.next()  # Next day
day + 1  # Next day
1 + day  # Next day
day.previous()  # Previous day
day - 1  # Previous day
day.next_weekday()  # Next day that is on a weekday
day.previous_weekday()  # Previous day that is on a weekday
day.plus_days(3)  # Add 3 days to the day
day + 3
day.plus_days(-3)  # Subtract 3 days from the day
day.plus_weeks(1)  # Add 1 week to the day
day.plus_months(1)  # Add 1 month to the day
~~~~


### Comparing days
~~~~python
day1 = Day('2022-08-16')
day2 = Day('2022-08-20')
day2 > day1  # Returns True if day2 is after day1
day2 == day1  # Returns True if day2 is the same day as day1
days_difference = day2 - day1  # Returns the difference in days between two days (4)
~~~~

### Miscellaneous
~~~~python
day.is_weekend()  # Returns True if the day is a weekend
day.is_weekday()  # Returns True if the day is a weekday
day.day_of_week()  # Returns the day of the week as an integer (0 = Monday, 6 = Sunday)
day.day_of_year()  # Returns the day of the year as an integer (1 = 1st of January, 365 = 31st of December in a non leap year)
day.fraction_of_the_year_past()  # Returns the fraction of the year that has passed (0.0 = 1st of January, 1.0 = 31st of December)
day.week_number()  # Returns the week number of the year (1 = first week of the year, 52 = last week of the year)
day.last_monday()  # Returns the last day that was a Monday or the day itself if it is a Monday
day.last_day_of_month()  # Returns the last day of the month of the day
day + ' is a nice day'  # Add string to a day
'The date is ' + day  # Add string to a day
~~~~


## Period class usage
Period is just a day range. Either fromday or untilday can be left to None

### Initializing a Period
~~~~python
period = Period(day1, day2)  # Period ranging from day1 (included) until day2 (not included)
period = Period(day1)  # One argument: fromday. Untilday is left open
period = Period('2022-08-16', '2022-08-20')  # Period can be initialized with strings in YYYY-MM-DD format
period = Period.from_week(2022, 32)  # Period ranging from the Monday of week 32 until the Sunday of week 32
period = Period.from_month(2022, 8)  # Period ranging from the 1st of August until the 31st of August
~~~~

### Accessing Period fields
~~~~python
fromday = period.fromday
untilday = period.untilday
length = len(period)
~~~~

### Iterating over a Period
~~~~python
for day in period:
    print(day)
~~~~

### Checking if a Day falls within a Period
~~~~python
if day in period:
    print('yes!')
~~~~

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "justdays",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "days,adding days,difference between days,range of days,last Monday",
    "author": "",
    "author_email": "HP Harmsen <hp@harmsen.nl>",
    "download_url": "https://files.pythonhosted.org/packages/df/f7/e9824cf2d27bc25a6dfe8369a7ad7e78e0b2d5afa275990a76148631459d/justdays-1.8.4.tar.gz",
    "platform": null,
    "description": "# Justdays\n\nPackage to make working with days and ranges of days in Python super easy.\n\nThe package contains two classes: \\\n**Day** handles everything you want to do with days. \\\n**Period** handles a range of Day objects.\n\nCurrent version: 1.8.4\n\n## Installation\n~~~~bash\npython -m pip install justdays\n~~~~\n\n## Day class usage\n\n### Initializing a Day\n~~~~python\nday = Day()  # No arguments, initalize with the current day\nday = Day('2022-08-16')  # One argument, string in YYYY-MM-DD format\nday = Day(2022, 32)  # Two arguments: year, week. Day with be the Monday of that week\nday = Day(2022, 8, 16)  # Three arguments: year, month, day. \nday = Day(datetime(2022, 8, 16))  # Initialize with Python datetime object\nday = Day(date(2022, 8, 16))  # Initialize with Python date object\n~~~~\n\n### Accessing Day fields\n~~~~python\nd = day.d  # int\nm = day.m  # int\ny = day.y  # int\nas_string = day.str  # in YYYY-MM-DD format\n~~~~\n\n### Represenation\n~~~~python\nstr(day) # Returns the day in YYYY-MM-DD format\nday.as_datetime() # Returns the day as a Python datetime object\nday.as_date() # Returns the day as a Python date object\nday.strftime(format_string) # Returns the day as a string formatted according to the format string\nday.as_unix_timestamp() # Returns the day as a unix timestamp (int)\n~~~~\n\n### Days further away or in the past\n~~~~python\nday.next()  # Next day\nday + 1  # Next day\n1 + day  # Next day\nday.previous()  # Previous day\nday - 1  # Previous day\nday.next_weekday()  # Next day that is on a weekday\nday.previous_weekday()  # Previous day that is on a weekday\nday.plus_days(3)  # Add 3 days to the day\nday + 3\nday.plus_days(-3)  # Subtract 3 days from the day\nday.plus_weeks(1)  # Add 1 week to the day\nday.plus_months(1)  # Add 1 month to the day\n~~~~\n\n\n### Comparing days\n~~~~python\nday1 = Day('2022-08-16')\nday2 = Day('2022-08-20')\nday2 > day1  # Returns True if day2 is after day1\nday2 == day1  # Returns True if day2 is the same day as day1\ndays_difference = day2 - day1  # Returns the difference in days between two days (4)\n~~~~\n\n### Miscellaneous\n~~~~python\nday.is_weekend()  # Returns True if the day is a weekend\nday.is_weekday()  # Returns True if the day is a weekday\nday.day_of_week()  # Returns the day of the week as an integer (0 = Monday, 6 = Sunday)\nday.day_of_year()  # Returns the day of the year as an integer (1 = 1st of January, 365 = 31st of December in a non leap year)\nday.fraction_of_the_year_past()  # Returns the fraction of the year that has passed (0.0 = 1st of January, 1.0 = 31st of December)\nday.week_number()  # Returns the week number of the year (1 = first week of the year, 52 = last week of the year)\nday.last_monday()  # Returns the last day that was a Monday or the day itself if it is a Monday\nday.last_day_of_month()  # Returns the last day of the month of the day\nday + ' is a nice day'  # Add string to a day\n'The date is ' + day  # Add string to a day\n~~~~\n\n\n## Period class usage\nPeriod is just a day range. Either fromday or untilday can be left to None\n\n### Initializing a Period\n~~~~python\nperiod = Period(day1, day2)  # Period ranging from day1 (included) until day2 (not included)\nperiod = Period(day1)  # One argument: fromday. Untilday is left open\nperiod = Period('2022-08-16', '2022-08-20')  # Period can be initialized with strings in YYYY-MM-DD format\nperiod = Period.from_week(2022, 32)  # Period ranging from the Monday of week 32 until the Sunday of week 32\nperiod = Period.from_month(2022, 8)  # Period ranging from the 1st of August until the 31st of August\n~~~~\n\n### Accessing Period fields\n~~~~python\nfromday = period.fromday\nuntilday = period.untilday\nlength = len(period)\n~~~~\n\n### Iterating over a Period\n~~~~python\nfor day in period:\n    print(day)\n~~~~\n\n### Checking if a Day falls within a Period\n~~~~python\nif day in period:\n    print('yes!')\n~~~~\n",
    "bugtrack_url": null,
    "license": "This is free and unencumbered software released into the public domain.  Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.  In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  For more information, please refer to <https://unlicense.org> ",
    "summary": "Makes working with days super easy",
    "version": "1.8.4",
    "split_keywords": [
        "days",
        "adding days",
        "difference between days",
        "range of days",
        "last monday"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "a0905838b30afbcd18a0ccc1ada1796a",
                "sha256": "968c0a1242704dbb68c350f026a038bd1320d70aa6b99d86588131a99401a530"
            },
            "downloads": -1,
            "filename": "justdays-1.8.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a0905838b30afbcd18a0ccc1ada1796a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6924,
            "upload_time": "2023-01-02T14:03:32",
            "upload_time_iso_8601": "2023-01-02T14:03:32.424619Z",
            "url": "https://files.pythonhosted.org/packages/28/96/f01e5286c7fa670d075b24f9b129f23b7a8b0a362f378bd25ce183073e2b/justdays-1.8.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "1f464ec998ba3e687d54dfc74e0988b0",
                "sha256": "2989293751d2f7646345f70ed8fb3c9e1dabf966289095f0611ad7114fc582df"
            },
            "downloads": -1,
            "filename": "justdays-1.8.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1f464ec998ba3e687d54dfc74e0988b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5827,
            "upload_time": "2023-01-02T14:03:33",
            "upload_time_iso_8601": "2023-01-02T14:03:33.913263Z",
            "url": "https://files.pythonhosted.org/packages/df/f7/e9824cf2d27bc25a6dfe8369a7ad7e78e0b2d5afa275990a76148631459d/justdays-1.8.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-02 14:03:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "justdays"
}
        
Elapsed time: 0.02856s