diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-beautiful-date.spec | 905 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 907 insertions, 0 deletions
@@ -0,0 +1 @@ +/beautiful-date-2.2.0.tar.gz diff --git a/python-beautiful-date.spec b/python-beautiful-date.spec new file mode 100644 index 0000000..39d0405 --- /dev/null +++ b/python-beautiful-date.spec @@ -0,0 +1,905 @@ +%global _empty_manifest_terminate_build 0 +Name: python-beautiful-date +Version: 2.2.0 +Release: 1 +Summary: Simple and beautiful way to create date and datetime objects in Python. +License: MIT +URL: https://github.com/kuzmoyev/beautiful-date +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/1b/d3/82f10615457864b92c42e8e31502f273b485364af30b8690d2142176e9e6/beautiful-date-2.2.0.tar.gz +BuildArch: noarch + +Requires: python3-dateutil +Requires: python3-six + +%description + +# Beautiful Date + +[](https://badge.fury.io/py/beautiful-date) +[](https://github.com/kuzmoyev/beautiful-date/actions) +[](https://pepy.tech/project/beautiful-date) + +Simple and beautiful way to create date and datetime objects in Python. + +**Before**: + +```python3 +from datetime import date, datetime + +d = date(year=2018, month=3, day=25) +t = datetime(year=2018, month=3, day=25, hour=23, minute=45) +``` + +**After**: + +```python3 +from beautiful_date import * + +d = 25/Mar/2018 +t = (25/Mar/2018)[23:45] +``` + +## Installation + +```bash +pip install beautiful-date +``` + +## Examples + +### Create Date + +Using months names: + +```python3 +>>> from beautiful_date import * + +>>> 25/Mar/2018 # European format +BeautifulDate(2018, 3, 25) +>>> Mar/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Using months numbers: + +```python3 +>>> 25/M[3]/2018 # European format +BeautifulDate(2018, 3, 25) +>>> M[3]/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Or alternatively: + +```python3 +>>> D @ 25/3/2018 # European format (default) +BeautifulDate(2018, 3, 25) + +>>> D = MDY() # Add this at the top of your script to use US format. +>>> d = D @ 3/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Available formats (needed only if you create dates using `D@`): + +```python3 +class DMY(BaseDateFormat): + _format = 'day', 'month', 'year' + +class MDY(BaseDateFormat): + _format = 'month', 'day', 'year' + +class YMD(BaseDateFormat): + _format = 'year', 'month', 'day' + +class YDM(BaseDateFormat): + _format = 'year', 'day', 'month' +``` + +You can also easily retrieve current date as a `BeautifulDate` object and current time using: + +```python3 +>>> D.today() +BeautifulDate(2020, 8, 24) + +>>> D.now() +datetime.datetime(2020, 8, 24, 0, 59, 12, 451363) +``` + +### Create Datetime + +Previous methods create `BeautifulDate` objects which are inherited from `date` but can be +easily extended to `datetime` using indexing/slicing: + +```python3 +>>> (Oct/16/1995)[:] +datetime.datetime(1995, 10, 16, 0, 0) + +>>> (Oct/16/1995)[23] +datetime.datetime(1995, 10, 16, 23, 0) + +>>> (Oct/16/1995)[23:14] +datetime.datetime(1995, 10, 16, 23, 14) + +>>> (Oct/16/1995)[23:14:10] +datetime.datetime(1995, 10, 16, 23, 14, 10) +``` + +You can also use prefix `D @` if you need months by their numbers: + +```python3 +>>> (D @ 16/10/1995)[:] +datetime.datetime(1995, 10, 16, 0, 0) + +>>> (D @ 16/10/1995)[23] +datetime.datetime(1995, 10, 16, 23, 0) + +>>> (D @ 16/10/1995)[23:14] +datetime.datetime(1995, 10, 16, 23, 14) + +>>> (D @ 16/10/1995)[23:14:10] +datetime.datetime(1995, 10, 16, 23, 14, 10) +``` + +### Date/Datetime manipulations: + +This library also provides simple interface for +[relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html) from +[dateutil](http://dateutil.readthedocs.io/en/stable/index.html) + +#### Adding/Subtracting/Setting timedeltas: + +Notice that singular time unit (year, month, ...) sets given value, plural (years, months,) adds it. + + +```python3 +>>> d = 26/Mar/2018 +>>> t = d[12:23:15] + +>>> d + 2 * years +BeautifulDate(2020, 3, 26) +>>> d - 2 * days +BeautifulDate(2018, 3, 24) + +>>> t + 25 * hours +datetime.datetime(2018, 3, 27, 13, 23, 15) +``` + +Available deltas: `years`, `months`, `weeks`, `days`, `hours`, `minutes`, +`seconds`, `microseconds`, `leapdays` +(see [relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html)). + +```python3 +>>> d = 26/Mar/2018 +>>> t = d[12:23:15] + +>>> d + 2022 * year +BeautifulDate(2022, 3, 26) +>>> d += 2 * day +>>> d +BeautifulDate(2018, 3, 2) + +>>> t + 22 * hour +datetime.datetime(2018, 3, 26, 22, 23, 15) +>>> t += 22 * hour +>>> t +datetime.datetime(2018, 3, 26, 22, 23, 15) +``` + +Available setters: `year`, `month`, `day`, `hour`, `minute`, `second`, `microsecond`, +`yearday` and `nlyearday` +(see [relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html)). + +#### Weekdays: + +Get next Monday: + +```python3 +>>> d = 29/Mar/2018 # Thursday +>>> d + MO # Equivalent to MO(1) +BeautifulDate(2018, 4, 2) +``` + +Get second to next Monday: + +```python3 +>>> d = 29/Mar/2018 +>>> d + MO(2) +BeautifulDate(2018, 4, 9) +``` + +Get last Saturday: + +```python3 +>>> d = 29/Mar/2018 +>>> d - SA +BeautifulDate(2018, 3, 24) +``` + +Get second to last Saturday: + +```python3 +>>> d = 29/Mar/2018 +>>> d - SA(2) +BeautifulDate(2018, 3, 17) +``` + +Get second to last Saturday (same as previous): + +```python3 +>>> d = 29/Mar/2018 +>>> d + SA(-2) +BeautifulDate(2018, 3, 17) +``` + +### Util + +#### drange: + +You can use `drange` to generate ranges of dates: + +```python3 +>>> for d in drange(27/Mar/1994, 5/Apr/1994): +... print(d) +1994-03-27 +1994-03-28 +1994-03-29 +1994-03-30 +1994-03-31 +1994-04-01 +1994-04-02 +1994-04-03 +1994-04-04 + +>>> for d in drange(27/Mar/1994, 5/Apr/1994, 2*days): +... print(d) +1994-03-27 +1994-03-29 +1994-03-31 +1994-04-02 +1994-04-04 +``` + +and datetimes: + +```python3 +>>> for dt in drange((27/Mar/1994)[10:25], (4/Apr/1994)[10:10]): +... print(dt) +1994-03-27 10:25:00 +1994-03-28 10:25:00 +1994-03-29 10:25:00 +1994-03-30 10:25:00 +1994-03-31 10:25:00 +1994-04-01 10:25:00 +1994-04-02 10:25:00 +1994-04-03 10:25:00 + +>>> for dt in drange((27/Mar/1994)[10:25], (4/Apr/1994)[10:10], 20*hours): +... print(dt) +1994-03-27 10:25:00 +1994-03-28 06:25:00 +1994-03-29 02:25:00 +1994-03-29 22:25:00 +1994-03-30 18:25:00 +1994-03-31 14:25:00 +1994-04-01 10:25:00 +1994-04-02 06:25:00 +1994-04-03 02:25:00 +1994-04-03 22:25:00 +``` + + + + +%package -n python3-beautiful-date +Summary: Simple and beautiful way to create date and datetime objects in Python. +Provides: python-beautiful-date +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-beautiful-date + +# Beautiful Date + +[](https://badge.fury.io/py/beautiful-date) +[](https://github.com/kuzmoyev/beautiful-date/actions) +[](https://pepy.tech/project/beautiful-date) + +Simple and beautiful way to create date and datetime objects in Python. + +**Before**: + +```python3 +from datetime import date, datetime + +d = date(year=2018, month=3, day=25) +t = datetime(year=2018, month=3, day=25, hour=23, minute=45) +``` + +**After**: + +```python3 +from beautiful_date import * + +d = 25/Mar/2018 +t = (25/Mar/2018)[23:45] +``` + +## Installation + +```bash +pip install beautiful-date +``` + +## Examples + +### Create Date + +Using months names: + +```python3 +>>> from beautiful_date import * + +>>> 25/Mar/2018 # European format +BeautifulDate(2018, 3, 25) +>>> Mar/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Using months numbers: + +```python3 +>>> 25/M[3]/2018 # European format +BeautifulDate(2018, 3, 25) +>>> M[3]/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Or alternatively: + +```python3 +>>> D @ 25/3/2018 # European format (default) +BeautifulDate(2018, 3, 25) + +>>> D = MDY() # Add this at the top of your script to use US format. +>>> d = D @ 3/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Available formats (needed only if you create dates using `D@`): + +```python3 +class DMY(BaseDateFormat): + _format = 'day', 'month', 'year' + +class MDY(BaseDateFormat): + _format = 'month', 'day', 'year' + +class YMD(BaseDateFormat): + _format = 'year', 'month', 'day' + +class YDM(BaseDateFormat): + _format = 'year', 'day', 'month' +``` + +You can also easily retrieve current date as a `BeautifulDate` object and current time using: + +```python3 +>>> D.today() +BeautifulDate(2020, 8, 24) + +>>> D.now() +datetime.datetime(2020, 8, 24, 0, 59, 12, 451363) +``` + +### Create Datetime + +Previous methods create `BeautifulDate` objects which are inherited from `date` but can be +easily extended to `datetime` using indexing/slicing: + +```python3 +>>> (Oct/16/1995)[:] +datetime.datetime(1995, 10, 16, 0, 0) + +>>> (Oct/16/1995)[23] +datetime.datetime(1995, 10, 16, 23, 0) + +>>> (Oct/16/1995)[23:14] +datetime.datetime(1995, 10, 16, 23, 14) + +>>> (Oct/16/1995)[23:14:10] +datetime.datetime(1995, 10, 16, 23, 14, 10) +``` + +You can also use prefix `D @` if you need months by their numbers: + +```python3 +>>> (D @ 16/10/1995)[:] +datetime.datetime(1995, 10, 16, 0, 0) + +>>> (D @ 16/10/1995)[23] +datetime.datetime(1995, 10, 16, 23, 0) + +>>> (D @ 16/10/1995)[23:14] +datetime.datetime(1995, 10, 16, 23, 14) + +>>> (D @ 16/10/1995)[23:14:10] +datetime.datetime(1995, 10, 16, 23, 14, 10) +``` + +### Date/Datetime manipulations: + +This library also provides simple interface for +[relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html) from +[dateutil](http://dateutil.readthedocs.io/en/stable/index.html) + +#### Adding/Subtracting/Setting timedeltas: + +Notice that singular time unit (year, month, ...) sets given value, plural (years, months,) adds it. + + +```python3 +>>> d = 26/Mar/2018 +>>> t = d[12:23:15] + +>>> d + 2 * years +BeautifulDate(2020, 3, 26) +>>> d - 2 * days +BeautifulDate(2018, 3, 24) + +>>> t + 25 * hours +datetime.datetime(2018, 3, 27, 13, 23, 15) +``` + +Available deltas: `years`, `months`, `weeks`, `days`, `hours`, `minutes`, +`seconds`, `microseconds`, `leapdays` +(see [relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html)). + +```python3 +>>> d = 26/Mar/2018 +>>> t = d[12:23:15] + +>>> d + 2022 * year +BeautifulDate(2022, 3, 26) +>>> d += 2 * day +>>> d +BeautifulDate(2018, 3, 2) + +>>> t + 22 * hour +datetime.datetime(2018, 3, 26, 22, 23, 15) +>>> t += 22 * hour +>>> t +datetime.datetime(2018, 3, 26, 22, 23, 15) +``` + +Available setters: `year`, `month`, `day`, `hour`, `minute`, `second`, `microsecond`, +`yearday` and `nlyearday` +(see [relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html)). + +#### Weekdays: + +Get next Monday: + +```python3 +>>> d = 29/Mar/2018 # Thursday +>>> d + MO # Equivalent to MO(1) +BeautifulDate(2018, 4, 2) +``` + +Get second to next Monday: + +```python3 +>>> d = 29/Mar/2018 +>>> d + MO(2) +BeautifulDate(2018, 4, 9) +``` + +Get last Saturday: + +```python3 +>>> d = 29/Mar/2018 +>>> d - SA +BeautifulDate(2018, 3, 24) +``` + +Get second to last Saturday: + +```python3 +>>> d = 29/Mar/2018 +>>> d - SA(2) +BeautifulDate(2018, 3, 17) +``` + +Get second to last Saturday (same as previous): + +```python3 +>>> d = 29/Mar/2018 +>>> d + SA(-2) +BeautifulDate(2018, 3, 17) +``` + +### Util + +#### drange: + +You can use `drange` to generate ranges of dates: + +```python3 +>>> for d in drange(27/Mar/1994, 5/Apr/1994): +... print(d) +1994-03-27 +1994-03-28 +1994-03-29 +1994-03-30 +1994-03-31 +1994-04-01 +1994-04-02 +1994-04-03 +1994-04-04 + +>>> for d in drange(27/Mar/1994, 5/Apr/1994, 2*days): +... print(d) +1994-03-27 +1994-03-29 +1994-03-31 +1994-04-02 +1994-04-04 +``` + +and datetimes: + +```python3 +>>> for dt in drange((27/Mar/1994)[10:25], (4/Apr/1994)[10:10]): +... print(dt) +1994-03-27 10:25:00 +1994-03-28 10:25:00 +1994-03-29 10:25:00 +1994-03-30 10:25:00 +1994-03-31 10:25:00 +1994-04-01 10:25:00 +1994-04-02 10:25:00 +1994-04-03 10:25:00 + +>>> for dt in drange((27/Mar/1994)[10:25], (4/Apr/1994)[10:10], 20*hours): +... print(dt) +1994-03-27 10:25:00 +1994-03-28 06:25:00 +1994-03-29 02:25:00 +1994-03-29 22:25:00 +1994-03-30 18:25:00 +1994-03-31 14:25:00 +1994-04-01 10:25:00 +1994-04-02 06:25:00 +1994-04-03 02:25:00 +1994-04-03 22:25:00 +``` + + + + +%package help +Summary: Development documents and examples for beautiful-date +Provides: python3-beautiful-date-doc +%description help + +# Beautiful Date + +[](https://badge.fury.io/py/beautiful-date) +[](https://github.com/kuzmoyev/beautiful-date/actions) +[](https://pepy.tech/project/beautiful-date) + +Simple and beautiful way to create date and datetime objects in Python. + +**Before**: + +```python3 +from datetime import date, datetime + +d = date(year=2018, month=3, day=25) +t = datetime(year=2018, month=3, day=25, hour=23, minute=45) +``` + +**After**: + +```python3 +from beautiful_date import * + +d = 25/Mar/2018 +t = (25/Mar/2018)[23:45] +``` + +## Installation + +```bash +pip install beautiful-date +``` + +## Examples + +### Create Date + +Using months names: + +```python3 +>>> from beautiful_date import * + +>>> 25/Mar/2018 # European format +BeautifulDate(2018, 3, 25) +>>> Mar/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Using months numbers: + +```python3 +>>> 25/M[3]/2018 # European format +BeautifulDate(2018, 3, 25) +>>> M[3]/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Or alternatively: + +```python3 +>>> D @ 25/3/2018 # European format (default) +BeautifulDate(2018, 3, 25) + +>>> D = MDY() # Add this at the top of your script to use US format. +>>> d = D @ 3/25/2018 # US format +BeautifulDate(2018, 3, 25) +``` + +Available formats (needed only if you create dates using `D@`): + +```python3 +class DMY(BaseDateFormat): + _format = 'day', 'month', 'year' + +class MDY(BaseDateFormat): + _format = 'month', 'day', 'year' + +class YMD(BaseDateFormat): + _format = 'year', 'month', 'day' + +class YDM(BaseDateFormat): + _format = 'year', 'day', 'month' +``` + +You can also easily retrieve current date as a `BeautifulDate` object and current time using: + +```python3 +>>> D.today() +BeautifulDate(2020, 8, 24) + +>>> D.now() +datetime.datetime(2020, 8, 24, 0, 59, 12, 451363) +``` + +### Create Datetime + +Previous methods create `BeautifulDate` objects which are inherited from `date` but can be +easily extended to `datetime` using indexing/slicing: + +```python3 +>>> (Oct/16/1995)[:] +datetime.datetime(1995, 10, 16, 0, 0) + +>>> (Oct/16/1995)[23] +datetime.datetime(1995, 10, 16, 23, 0) + +>>> (Oct/16/1995)[23:14] +datetime.datetime(1995, 10, 16, 23, 14) + +>>> (Oct/16/1995)[23:14:10] +datetime.datetime(1995, 10, 16, 23, 14, 10) +``` + +You can also use prefix `D @` if you need months by their numbers: + +```python3 +>>> (D @ 16/10/1995)[:] +datetime.datetime(1995, 10, 16, 0, 0) + +>>> (D @ 16/10/1995)[23] +datetime.datetime(1995, 10, 16, 23, 0) + +>>> (D @ 16/10/1995)[23:14] +datetime.datetime(1995, 10, 16, 23, 14) + +>>> (D @ 16/10/1995)[23:14:10] +datetime.datetime(1995, 10, 16, 23, 14, 10) +``` + +### Date/Datetime manipulations: + +This library also provides simple interface for +[relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html) from +[dateutil](http://dateutil.readthedocs.io/en/stable/index.html) + +#### Adding/Subtracting/Setting timedeltas: + +Notice that singular time unit (year, month, ...) sets given value, plural (years, months,) adds it. + + +```python3 +>>> d = 26/Mar/2018 +>>> t = d[12:23:15] + +>>> d + 2 * years +BeautifulDate(2020, 3, 26) +>>> d - 2 * days +BeautifulDate(2018, 3, 24) + +>>> t + 25 * hours +datetime.datetime(2018, 3, 27, 13, 23, 15) +``` + +Available deltas: `years`, `months`, `weeks`, `days`, `hours`, `minutes`, +`seconds`, `microseconds`, `leapdays` +(see [relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html)). + +```python3 +>>> d = 26/Mar/2018 +>>> t = d[12:23:15] + +>>> d + 2022 * year +BeautifulDate(2022, 3, 26) +>>> d += 2 * day +>>> d +BeautifulDate(2018, 3, 2) + +>>> t + 22 * hour +datetime.datetime(2018, 3, 26, 22, 23, 15) +>>> t += 22 * hour +>>> t +datetime.datetime(2018, 3, 26, 22, 23, 15) +``` + +Available setters: `year`, `month`, `day`, `hour`, `minute`, `second`, `microsecond`, +`yearday` and `nlyearday` +(see [relativedelta](http://dateutil.readthedocs.io/en/stable/relativedelta.html)). + +#### Weekdays: + +Get next Monday: + +```python3 +>>> d = 29/Mar/2018 # Thursday +>>> d + MO # Equivalent to MO(1) +BeautifulDate(2018, 4, 2) +``` + +Get second to next Monday: + +```python3 +>>> d = 29/Mar/2018 +>>> d + MO(2) +BeautifulDate(2018, 4, 9) +``` + +Get last Saturday: + +```python3 +>>> d = 29/Mar/2018 +>>> d - SA +BeautifulDate(2018, 3, 24) +``` + +Get second to last Saturday: + +```python3 +>>> d = 29/Mar/2018 +>>> d - SA(2) +BeautifulDate(2018, 3, 17) +``` + +Get second to last Saturday (same as previous): + +```python3 +>>> d = 29/Mar/2018 +>>> d + SA(-2) +BeautifulDate(2018, 3, 17) +``` + +### Util + +#### drange: + +You can use `drange` to generate ranges of dates: + +```python3 +>>> for d in drange(27/Mar/1994, 5/Apr/1994): +... print(d) +1994-03-27 +1994-03-28 +1994-03-29 +1994-03-30 +1994-03-31 +1994-04-01 +1994-04-02 +1994-04-03 +1994-04-04 + +>>> for d in drange(27/Mar/1994, 5/Apr/1994, 2*days): +... print(d) +1994-03-27 +1994-03-29 +1994-03-31 +1994-04-02 +1994-04-04 +``` + +and datetimes: + +```python3 +>>> for dt in drange((27/Mar/1994)[10:25], (4/Apr/1994)[10:10]): +... print(dt) +1994-03-27 10:25:00 +1994-03-28 10:25:00 +1994-03-29 10:25:00 +1994-03-30 10:25:00 +1994-03-31 10:25:00 +1994-04-01 10:25:00 +1994-04-02 10:25:00 +1994-04-03 10:25:00 + +>>> for dt in drange((27/Mar/1994)[10:25], (4/Apr/1994)[10:10], 20*hours): +... print(dt) +1994-03-27 10:25:00 +1994-03-28 06:25:00 +1994-03-29 02:25:00 +1994-03-29 22:25:00 +1994-03-30 18:25:00 +1994-03-31 14:25:00 +1994-04-01 10:25:00 +1994-04-02 06:25:00 +1994-04-03 02:25:00 +1994-04-03 22:25:00 +``` + + + + +%prep +%autosetup -n beautiful-date-2.2.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-beautiful-date -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 2.2.0-1 +- Package Spec generated @@ -0,0 +1 @@ +54d9c5ce9146452c9c799b98ab8fed96 beautiful-date-2.2.0.tar.gz |
