Skip to content

Commit 375971c

Browse files
authored
Merge pull request #51 from seatable/dateutils-add-isomonth
Dateutils add isomonth
2 parents add5e60 + c9792c7 commit 375971c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

demo/dateutils_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@
8080

8181
print(dateutils.isoweeknum('2012-1-2')) # 1, monday
8282
print(dateutils.weeknum('2012-1-2')) # 2, monday
83+
84+
# 19. dateutils.isomonth
85+
print(dateutils.isomonth('2012-1-2'))

seatable_api/date_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,13 @@ def isoweeknum(self, time_str):
202202
"""
203203
return self._str2datetime(time_str).isocalendar()[1]
204204

205+
def isomonth(self, time_str):
206+
year = self.year(time_str)
207+
month = self.month(time_str)
208+
209+
date_str = self.date(year, month, 1)
210+
return date_str[0:-3]
211+
212+
205213

206214
dateutils = DateUtils()

0 commit comments

Comments
 (0)