Package: past-date2word
past_date2wordpast_date2word is library helps you to convert the past date to textRequirementsInstallationExamplesEnglishSecondsMinutesHoursDaysWeeksMonthsYearsArabicSecondsMinutesHoursDaysWeeksMonthsYearsLicenseRequirementspython3.8+gitpip3InstallationUsePyPito install past_date2word.pip3installpast_date2wordExampleNOTE: Not all cases will be written because they are many, do not worry, you can see thetests filethat contains all the possible cases (if you think otherwise, add the test and do a PR, we will be happy with that)NOTE:with_agoparameter will add"ago"to the end of the sentence if itsTrue, and if not, he will not add itNOTE:long_sentenceparameter will add the hours, minutes and seconds to the sentence if itsTrue, and if not, he will not add itEnglishSeconds ENtime=datetime.now()-timedelta(seconds=1)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=True)=="1 second"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=False)=="1 second ago"# Output of past_date2word)[Back To Top 🔝]Minutes ENtime=datetime.now()-timedelta(minutes=9,seconds=34)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=True)=="9 minutes and 34 seconds ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=True)=="9 minutes and 34 seconds"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=False)=="9 minutes ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=False)=="9 minutes"# Output of past_date2word)[Back To Top 🔝]Hours ENtime=datetime.now()-timedelta(hours=12,minutes=44)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=True)=="12 hours and 44 minutes ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=True)=="12 hours and 44 minutes"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=False)=="12 hours ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=False)=="12 hours"# Output of past_date2word)[Back To Top 🔝]Days ENtime=datetime.now()-timedelta(days=5,hours=15)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=True)=="5 days and 15 hours ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=True)=="5 days and 15 hours"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=False)=="5 days ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=False)=="5 days"# Output of past_date2word)[Back To Top 🔝]Weeks ENtime=datetime.now()-timedelta(weeks=2,days=4)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=True)=="2 weeks and 4 days ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=True)=="2 weeks and 4 days"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=False)=="2 weeks and 4 days ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=False)=="2 weeks and 4 days"# Output of past_date2word)[Back To Top 🔝]Months EN# 4 weeks == 1 monthone_month_to_week=4*1time=datetime.now()-timedelta(weeks=(one_month_to_week*3)+2)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=True)=="3 months and 2 weeks ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=True)=="3 months and 2 weeks"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=False)=="3 months and 2 weeks ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=False)=="3 months and 2 weeks"# Output of past_date2word)[Back To Top 🔝]Years EN# 12 month == 1 year# 4 weeks == 1 monthone_month_to_week=4*1one_year_to_week=one_month_to_week*12time=datetime.now()-timedelta(weeks=(one_year_to_week*12)+(one_month_to_week*5))assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=True)=="12 years and 5 months ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=True)=="12 years and 5 months"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=True,long_sentence=False)=="12 years and 5 months ago"# Output of past_date2word)assert(past_date2word(date=time,language="en",with_ago=False,long_sentence=False)=="12 years and 5 months"# Output of past_date2word)[Back To Top 🔝]ArabicSeconds ARtime=datetime.now()-timedelta(seconds=13)print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=False))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=False))المخرجات"منذ 13 ثانية"
"13 ثانية"
"منذ 13 ثانية"
"13 ثانية"[Back To Top 🔝]Minutes ARtime=datetime.now()-timedelta(minutes=13,seconds=13)print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=False))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=False))المخرجات"منذ 13 دقيقة و 13 ثانية"
"13 دقيقة و 13 ثانية"
"منذ 13 دقيقة"
"13 دقيقة"[Back To Top 🔝]Hours ARtime=datetime.now()-timedelta(hours=13,minutes=13)print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=False))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=False))المخرجات"منذ 13 ساعة و 13 دقيقة"
"13 ساعة و 13 دقيقة"
"منذ 13 ساعة"
"13 ساعة"[Back To Top 🔝]Days ARtime=datetime.now()-timedelta(days=6,hours=15)print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=False))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=False))المخرجات"منذ 6 ايام و 15 ساعة"
"6 ايام و 15 ساعة"
"منذ 6 ايام"
"6 ايام"[Back To Top 🔝]Weeks ARtime=datetime.now()-timedelta(weeks=3,days=4)print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=False))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=False))المخرجات"منذ 3 اسابيع و 4 ايام"
"3 اسابيع و 4 ايام"
"منذ 3 اسابيع و 4 ايام"
"3 اسابيع و 4 ايام"[Back To Top 🔝]Months ARone_month_to_week=4*1time=datetime.now()-timedelta(weeks=(one_month_to_week*11)+3)print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=False))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=False))المخرجات"منذ 11 شهر و 3 اسابيع"
"11 شهر و 3 اسابيع"
"منذ 11 شهر و 3 اسابيع"
"11 شهر و 3 اسابيع"[Back To Top 🔝]Years AR# 12 month == 1 year# 4 weeks == 1 monthone_month_to_week=4*1one_year_to_week=one_month_to_week*12time=datetime.now()-timedelta(weeks=(one_year_to_week*12)+(one_month_to_week*5))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=True))print(past_date2word(date=time,language="ar",with_ago=True,long_sentence=False))print(past_date2word(date=time,language="ar",with_ago=False,long_sentence=False))المخرجات"منذ 12 سنة و 5 اشهر"
"12 سنة و 5 اشهر"
"منذ 12 سنة و 5 اشهر"
"12 سنة و 5 اشهر"LicenseGPLv3