feat(util): add is_last_day_of_the_month (#18835)

* feat: add is_last_day_of_the_month
This commit is contained in:
Anand Baburajan 2022-11-10 15:18:49 +05:30 committed by GitHub
parent a434b5fb0d
commit bc0abd9cfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -493,6 +493,10 @@ class TestDateUtils(FrappeTestCase):
frappe.utils.get_last_day_of_week("2020-12-28"), frappe.utils.getdate("2021-01-02")
)
def test_is_last_day_of_the_month(self):
self.assertEqual(frappe.utils.is_last_day_of_the_month("2020-12-24"), False)
self.assertEqual(frappe.utils.is_last_day_of_the_month("2020-12-31"), True)
def test_get_time(self):
datetime_input = now_datetime()
timedelta_input = get_timedelta()

View file

@ -471,6 +471,12 @@ def get_last_day(dt):
return get_first_day(dt, 0, 1) + datetime.timedelta(-1)
def is_last_day_of_the_month(dt):
last_day_of_the_month = get_last_day(dt)
return getdate(dt) == getdate(last_day_of_the_month)
def get_quarter_ending(date):
date = getdate(date)