Package: d8s-dates
Democritus DatesDemocritus functions[1]for working with and using dates and times.[1] Democritus functions aresimple, effective, modular, well-tested, and well-documentedPython functions.We used8s(pronounced "dee-eights") as an abbreviation fordemocritus(you can read more about thishere).Installationpip install d8s-datesUsageYou import the library like:fromd8s_datesimport*Once imported, you can use any of the functions listed below.Functionsdefdate_string_to_strftime_format(date_string):"""Predict the strftime format from the given date_string."""defdate_parse(date,*,convert_to_current_timezone:bool=False):"""Parse the given date (can parse dates in most formats) (returns a datetime object)."""defdate_now(*,convert_to_current_timezone:bool=False,utc:bool=False):"""Get the current date.If convert_to_current_timezone is True, convert the date to the current timezone.If utc is True, convert the date to UTC."""defdate_parse_first_argument(func):"""."""defdate_2_string(date,date_format_string:str):"""."""defdate_hour(date):"""Find the hour from the given date."""defdate_minute(date):"""Find the minute from the given date."""defdate_second(date):"""Find the second from the given date."""defdate_day(date):"""Find the day of the month from the given date."""defdate_day_of_month(date):"""Find the day of the month from the given date."""defdate_month(date):"""Find the month from the given date."""defdate_year(date):"""Find the year from the given date."""defdate_convert_to_timezone(date,timezone_string):"""Convert the given date to the given timezone_string.This will actually **convert** time given date; it will change the hour/day of the date to the given timezone)."""defdate_make_timezone_aware(datetime_object,timezone_string=None):"""Make the given datetime_object timezone aware.This function does NOT convert the datetime_object.It will never change the hour/day or any value of the datetime...it will simply make the given datetime timezone aware."""deftime_delta_examples(n=10,*,time_deltas_as_strings:bool=True):"""Return n time deltas."""deftime_examples(n=10,*,times_as_strings:bool=True):"""Return n times."""defdate_examples(n=10,*,dates_as_strings:bool=True,date_string_format:str=None):"""Return n dates."""defdatetime_examples(n=10,*,datetimes_as_strings:bool=True,datetime_string_format:str=None):"""Return n datetimes."""deftime_struct_to_datetime(struct_time_object):"""Convert a python time.struct_time object into a datetime object."""defepoch_time_now():"""Get the current epoch time."""defis_date(possible_date_string):"""Determine if the given possible_date_string can be processed as a date."""deftime_now():"""Return the current, epoch time."""deftime_since(date):"""Return a time of the time since the given date."""deftime_until(date):"""Return an English description of the time since the given date."""deftime_since_slang(date):"""Return an English description of the time since the given date."""deftime_until_slang(date):"""Return an English description of the time until the given date."""defdate_to_utc(date):"""Convert the given date to UTC. Assume that the given date is in the system's timezone and convert it to UTC."""deftime_after(time_a,time_b=None)->bool:"""Check if one time is before the other."""deftime_before(time_a,time_b=None)->bool:"""Check if one time is before the other."""defdate_in_future(date)->bool:"""Return whether or not the given date is in the future."""deftime_is()->str:"""Time and money spent in helping men to do more for themselves is far better than mere giving. -Henry Ford"""defdate_to_iso(date,*,timezone_is_utc:bool=False,use_trailing_z:bool=False):"""Return the ISO 8601 version of the given date as a string (see https://en.wikipedia.org/wiki/ISO_8601)."""defepoch_time_standardization(epoch_time):"""Convert the given epoch time to an epoch time in seconds."""defepoch_to_date(epoch_time):"""Convert the epoch_time into a datetime."""defdate_day_of_week(date):"""Return the day of the week on which the given date occurred."""defdate_week_of_year(date,*,sunday_is_first_day_of_week:bool=False):"""Find the week of the year for the given date. If no date is given, return the week of the current date."""defdate_to_epoch(date):"""Convert a datetime stamp to epoch time."""defchrome_timestamp_to_epoch(chrome_timestamp):"""Convert the given Chrome timestamp to epoch time.For more information, see: https://stackoverflow.com/questions/20458406/what-is-the-format-of-chromes-timestamps."""deftime_waste(n=3):"""If time be of all things the most precious, wasting time must be the greatest prodigality. -Benjamin Franklin"""deftime_as_float(time_string:str)->float:"""converts a given HH:MM time string to float"""Development👋  If you want to get involved in this project, we have some short, helpful guides below:contribute to this project 🥇test it 🧪lint it 🧹explore it 🔭If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.CreditsThis package was created withCookiecutterand Floyd Hightower'sPython project template.