Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

应使用shift函数而非replace #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions TimeUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ def norm_setCurRelated(self):
rule = u"上"
pattern = re.compile(rule)
match = pattern.findall(self.exp_time)
cur = cur.replace(weeks=-len(match), days=span)
cur = cur.shift(weeks=-len(match), days=span)

rule = u"(?<=((?<!上)上(周|星期)))[1-7]?"
pattern = re.compile(rule)
Expand All @@ -871,7 +871,7 @@ def norm_setCurRelated(self):
week = 1
week -= 1
span = week - cur.weekday()
cur = cur.replace(weeks=-1, days=span)
cur = cur.shift(weeks=-1, days=span)

rule = u"(?<=((?<!下)下(周|星期)))[1-7]?"
pattern = re.compile(rule)
Expand All @@ -884,7 +884,7 @@ def norm_setCurRelated(self):
week = 1
week -= 1
span = week - cur.weekday()
cur = cur.replace(weeks=1, days=span)
cur = cur.shift(weeks=1, days=span)

# 这里对下下下周的时间转换做出了改善
rule = u"(?<=(下*下下(周|星期)))[1-7]?"
Expand All @@ -901,7 +901,7 @@ def norm_setCurRelated(self):
rule = u"下"
pattern = re.compile(rule)
match = pattern.findall(self.exp_time)
cur = cur.replace(weeks=len(match), days=span)
cur = cur.shift(weeks=len(match), days=span)

rule = u"(?<=((?<!(上|下|个|[0-9]))(周|星期)))[1-7]"
pattern = re.compile(rule)
Expand All @@ -914,7 +914,7 @@ def norm_setCurRelated(self):
week = 1
week -= 1
span = week - cur.weekday()
cur = cur.replace(days=span)
cur = cur.shift(days=span)
# 处理未来时间
cur = self.preferFutureWeek(week, cur)

Expand Down