mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
Day first feature for dates added
This commit is contained in:
parent
d7a9518bb2
commit
0ac33effec
2 changed files with 5 additions and 5 deletions
|
@ -179,8 +179,8 @@ class Journal(object):
|
|||
If strict is True, all tags must be present in an entry. If false, the
|
||||
entry is kept if any tag is present."""
|
||||
self.search_tags = set([tag.lower() for tag in tags])
|
||||
end_date = time.parse(end_date, inclusive=True)
|
||||
start_date = time.parse(start_date)
|
||||
end_date = time.parse(end_date, inclusive=True, default_hour=self.config['default_hour'], default_minute=self.config['default_minute'], dayfirst=self.config['day_first'])
|
||||
start_date = time.parse(start_date, default_hour=self.config['default_hour'], default_minute=self.config['default_minute'], dayfirst=self.config['day_first'])
|
||||
|
||||
# If strict mode is on, all tags have to be present in entry
|
||||
tagged = self.search_tags.issubset if strict else self.search_tags.intersection
|
||||
|
@ -208,7 +208,7 @@ class Journal(object):
|
|||
if not date:
|
||||
colon_pos = first_line.find(": ")
|
||||
if colon_pos > 0:
|
||||
date = time.parse(raw[:colon_pos], default_hour=self.config['default_hour'], default_minute=self.config['default_minute'])
|
||||
date = time.parse(raw[:colon_pos], default_hour=self.config['default_hour'], default_minute=self.config['default_minute'], dayfirst=self.config['day_first'])
|
||||
if date: # Parsed successfully, strip that from the raw text
|
||||
starred = raw[:colon_pos].strip().endswith("*")
|
||||
raw = raw[colon_pos + 1:].strip()
|
||||
|
|
|
@ -12,7 +12,7 @@ consts.DOWParseStyle = -1 # "Monday" will be either today or the last Monday
|
|||
CALENDAR = pdt.Calendar(consts)
|
||||
|
||||
|
||||
def parse(date_str, inclusive=False, default_hour=None, default_minute=None):
|
||||
def parse(date_str, inclusive=False, default_hour=None, default_minute=None, dayfirst=False):
|
||||
"""Parses a string containing a fuzzy date and returns a datetime.datetime object"""
|
||||
if not date_str:
|
||||
return None
|
||||
|
@ -24,7 +24,7 @@ def parse(date_str, inclusive=False, default_hour=None, default_minute=None):
|
|||
year_present = False
|
||||
while not date:
|
||||
try:
|
||||
date = dateparse(date_str, default=default_date)
|
||||
date = dateparse(date_str, default=default_date, dayfirst=dayfirst)
|
||||
if date.year == FAKE_YEAR:
|
||||
date = datetime(datetime.now().year, date.timetuple()[1:6])
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue