%global _empty_manifest_terminate_build 0 Name: python-date-assistant Version: 0.11.2 Release: 1 Summary: 🗓 Classes and functions with intuitive names for common dates operations License: MIT URL: https://github.com/jalvaradosegura/date-assistant Source0: https://mirrors.aliyun.com/pypi/web/packages/07/cd/f50a70a9075d3d9d9cb1e51387126190c81f551d0b20a1e300b09e461595/date_assistant-0.11.2.tar.gz BuildArch: noarch Requires: python3-dateutil Requires: python3-pre-commit %description
# Date Assistant For more details take a look at the [docs](https://date-assistant.readthedocs.io) ## Installation date-assistant is published on [PyPI](https://pypi.org/project/date-assistant/) and can be installed from there: ``` pip install date-assistant ``` ## Usage > 💡 Please consider that the default date format is '%Y-%m-%d'. Anyways, you can indicate the format of your date if you need to. ### Functions approach #### Get the difference of days, months or years between 2 dates ```py from date_assistant import ( get_days_diff_between, get_months_diff_between, get_years_diff_between, ) from date_assistant.formats import DD_MM_YYYY, YYYY_MM get_days_diff_between('2021-01-01', '2021-01-11') # 10 get_days_diff_between('2021-01-01', '21-01-2021', date2_format=DD_MM_YYYY) # 20 get_months_diff_between('2021-01-01', '2022-01-11') # 12 get_months_diff_between('2021-01-05', '2021-02-01') # 0 get_months_diff_between('2021-01', '2021-02-21', date1_format=YYYY_MM) # 1 get_years_diff_between('2021-01-01', '2022-01-11') # 1 get_years_diff_between('2021-01-05', '2022-01-01') # 0 get_years_diff_between('2021-01', '2023-01-01', date1_format=YYYY_MM) # 2 ``` > 💡 See how months and years are only counted if a full year or month has passed. #### Get the amount of years or months started between 2 dates ```py from date_assistant import ( get_months_started_between, get_years_started_between, ) from date_assistant.formats import YYYY_MM get_months_started_between('2021-01-05', '2021-02-01') # 1 get_months_started_between('2021-01-01', '2022-01-11') # 12 get_months_started_between('2021-01', '2021-02-21', date1_format=YYYY_MM) # 1 get_years_started_between('2021-01-01', '2020-12-31') # 1 get_years_started_between('2021-01-05', '2022-01-01') # 1 get_years_started_between('2021-01', '2023-01-01', date1_format=YYYY_MM) # 2 ``` > 💡 In contrast with the previous block example, here you don't need a full year or month between dates to count. If a new year or month started, it count. ### Classes approach #### Get the difference of days, months or years between 2 dates ```py from date_assistant import DateAssistant my_birthday_2021 = DateAssistant('2021-07-13') date_assistant_birthday = '2021-08-18' my_birthday_2021.days_diff_with(date_assistant_birthday) # 36 my_birthday_2021.months_diff_with(date_assistant_birthday) # 1 my_birthday_2021.years_diff_with(date_assistant_birthday) # 0 ``` #### Get the amount of years or months started since or until some date ```py from date_assistant import DateAssistant last_day_of_2021 = DateAssistant('2021-12-31') first_day_of_2022 = '2022-01-01' first_day_of_2023 = '2023-01-01' date_assistant_birthday = '2021-08-18' last_day_of_2021.years_started_until(first_day_of_2022) # 1 last_day_of_2021.years_started_until(first_day_of_2023) # 2 last_day_of_2021.months_started_until(first_day_of_2022) # 1 last_day_of_2021.months_started_since(date_assistant_birthday) # 4 ``` %package -n python3-date-assistant Summary: 🗓 Classes and functions with intuitive names for common dates operations Provides: python-date-assistant BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-date-assistant # Date Assistant For more details take a look at the [docs](https://date-assistant.readthedocs.io) ## Installation date-assistant is published on [PyPI](https://pypi.org/project/date-assistant/) and can be installed from there: ``` pip install date-assistant ``` ## Usage > 💡 Please consider that the default date format is '%Y-%m-%d'. Anyways, you can indicate the format of your date if you need to. ### Functions approach #### Get the difference of days, months or years between 2 dates ```py from date_assistant import ( get_days_diff_between, get_months_diff_between, get_years_diff_between, ) from date_assistant.formats import DD_MM_YYYY, YYYY_MM get_days_diff_between('2021-01-01', '2021-01-11') # 10 get_days_diff_between('2021-01-01', '21-01-2021', date2_format=DD_MM_YYYY) # 20 get_months_diff_between('2021-01-01', '2022-01-11') # 12 get_months_diff_between('2021-01-05', '2021-02-01') # 0 get_months_diff_between('2021-01', '2021-02-21', date1_format=YYYY_MM) # 1 get_years_diff_between('2021-01-01', '2022-01-11') # 1 get_years_diff_between('2021-01-05', '2022-01-01') # 0 get_years_diff_between('2021-01', '2023-01-01', date1_format=YYYY_MM) # 2 ``` > 💡 See how months and years are only counted if a full year or month has passed. #### Get the amount of years or months started between 2 dates ```py from date_assistant import ( get_months_started_between, get_years_started_between, ) from date_assistant.formats import YYYY_MM get_months_started_between('2021-01-05', '2021-02-01') # 1 get_months_started_between('2021-01-01', '2022-01-11') # 12 get_months_started_between('2021-01', '2021-02-21', date1_format=YYYY_MM) # 1 get_years_started_between('2021-01-01', '2020-12-31') # 1 get_years_started_between('2021-01-05', '2022-01-01') # 1 get_years_started_between('2021-01', '2023-01-01', date1_format=YYYY_MM) # 2 ``` > 💡 In contrast with the previous block example, here you don't need a full year or month between dates to count. If a new year or month started, it count. ### Classes approach #### Get the difference of days, months or years between 2 dates ```py from date_assistant import DateAssistant my_birthday_2021 = DateAssistant('2021-07-13') date_assistant_birthday = '2021-08-18' my_birthday_2021.days_diff_with(date_assistant_birthday) # 36 my_birthday_2021.months_diff_with(date_assistant_birthday) # 1 my_birthday_2021.years_diff_with(date_assistant_birthday) # 0 ``` #### Get the amount of years or months started since or until some date ```py from date_assistant import DateAssistant last_day_of_2021 = DateAssistant('2021-12-31') first_day_of_2022 = '2022-01-01' first_day_of_2023 = '2023-01-01' date_assistant_birthday = '2021-08-18' last_day_of_2021.years_started_until(first_day_of_2022) # 1 last_day_of_2021.years_started_until(first_day_of_2023) # 2 last_day_of_2021.months_started_until(first_day_of_2022) # 1 last_day_of_2021.months_started_since(date_assistant_birthday) # 4 ``` %package help Summary: Development documents and examples for date-assistant Provides: python3-date-assistant-doc %description help # Date Assistant For more details take a look at the [docs](https://date-assistant.readthedocs.io) ## Installation date-assistant is published on [PyPI](https://pypi.org/project/date-assistant/) and can be installed from there: ``` pip install date-assistant ``` ## Usage > 💡 Please consider that the default date format is '%Y-%m-%d'. Anyways, you can indicate the format of your date if you need to. ### Functions approach #### Get the difference of days, months or years between 2 dates ```py from date_assistant import ( get_days_diff_between, get_months_diff_between, get_years_diff_between, ) from date_assistant.formats import DD_MM_YYYY, YYYY_MM get_days_diff_between('2021-01-01', '2021-01-11') # 10 get_days_diff_between('2021-01-01', '21-01-2021', date2_format=DD_MM_YYYY) # 20 get_months_diff_between('2021-01-01', '2022-01-11') # 12 get_months_diff_between('2021-01-05', '2021-02-01') # 0 get_months_diff_between('2021-01', '2021-02-21', date1_format=YYYY_MM) # 1 get_years_diff_between('2021-01-01', '2022-01-11') # 1 get_years_diff_between('2021-01-05', '2022-01-01') # 0 get_years_diff_between('2021-01', '2023-01-01', date1_format=YYYY_MM) # 2 ``` > 💡 See how months and years are only counted if a full year or month has passed. #### Get the amount of years or months started between 2 dates ```py from date_assistant import ( get_months_started_between, get_years_started_between, ) from date_assistant.formats import YYYY_MM get_months_started_between('2021-01-05', '2021-02-01') # 1 get_months_started_between('2021-01-01', '2022-01-11') # 12 get_months_started_between('2021-01', '2021-02-21', date1_format=YYYY_MM) # 1 get_years_started_between('2021-01-01', '2020-12-31') # 1 get_years_started_between('2021-01-05', '2022-01-01') # 1 get_years_started_between('2021-01', '2023-01-01', date1_format=YYYY_MM) # 2 ``` > 💡 In contrast with the previous block example, here you don't need a full year or month between dates to count. If a new year or month started, it count. ### Classes approach #### Get the difference of days, months or years between 2 dates ```py from date_assistant import DateAssistant my_birthday_2021 = DateAssistant('2021-07-13') date_assistant_birthday = '2021-08-18' my_birthday_2021.days_diff_with(date_assistant_birthday) # 36 my_birthday_2021.months_diff_with(date_assistant_birthday) # 1 my_birthday_2021.years_diff_with(date_assistant_birthday) # 0 ``` #### Get the amount of years or months started since or until some date ```py from date_assistant import DateAssistant last_day_of_2021 = DateAssistant('2021-12-31') first_day_of_2022 = '2022-01-01' first_day_of_2023 = '2023-01-01' date_assistant_birthday = '2021-08-18' last_day_of_2021.years_started_until(first_day_of_2022) # 1 last_day_of_2021.years_started_until(first_day_of_2023) # 2 last_day_of_2021.months_started_until(first_day_of_2022) # 1 last_day_of_2021.months_started_since(date_assistant_birthday) # 4 ``` %prep %autosetup -n date_assistant-0.11.2 %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-date-assistant -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue Jun 20 2023 Python_Bot