proof of concept shifting date
This commit is contained in:
parent
1f8e7a01db
commit
99b4d47e3c
1 changed files with 17 additions and 0 deletions
|
@ -89,6 +89,23 @@ timelog['description'] = (np.where(timelog['description'].str.contains(': '), ti
|
|||
timelog['description'] = timelog['description'].str.strip()
|
||||
timelog['project'] = timelog['project'].str.strip()
|
||||
|
||||
timelog['tmp_timeshift'] = timelog['description'].str.extract(r'^(\(.+)\)', expand=False)
|
||||
timelog['tmp_timeshift'] = timelog['tmp_timeshift'].str.strip().str.replace("(","")
|
||||
# In an ideal world we would use https://github.com/bear/parsedatetime or similar and
|
||||
# even better figure out the right date for strings like "Monday" but eh this'll do.
|
||||
timeshift_days = {
|
||||
-1: ['one day ago', '1 day ago', 'yesterday'],
|
||||
-2: ['two days ago', '2 days ago', 'day before yesterday', 'the day before yesterday'],
|
||||
-3: ['three days ago', '3 days ago'],
|
||||
-4: ['four days ago', '4 days ago'],
|
||||
-5: ['five days ago', '5 days ago'],
|
||||
}
|
||||
for days, phrases in timeshift_days.items():
|
||||
phrases.append(str(days))
|
||||
timelog.loc[timelog.tmp_timeshift.str.lower().isin(phrases), "tmp_daysdelta"] = int(days)
|
||||
timelog['tmp_daysdelta'] = timelog['tmp_daysdelta'].fillna(0)
|
||||
timelog['date'] = timelog['date'] + pd.to_timedelta(timelog['tmp_daysdelta'], unit='D')
|
||||
|
||||
# If a multiplier has been provided (an asterisk and an integer at the end of a
|
||||
# task), then multiply the time by it and remove it from the description.
|
||||
# Ensure we're splitting on the same asterisk we found: Use the end of string
|
||||
|
|
Loading…
Reference in a new issue