lib/timetrap/cli.rb in timetrap-1.14.2 vs lib/timetrap/cli.rb in timetrap-1.14.3
- old
+ new
@@ -43,10 +43,12 @@
require_note: Prompt for a note if one isn't provided when
checking in
note_editor: Command to launch notes editor or false if no editor use.
If you use a non terminal based editor (e.g. sublime, atom)
please read the notes in the README.
+ week_start: The day of the week to use as the start of the
+ week for t week.
* display - Display the current timesheet or a specific. Pass `all' as SHEET
to display all unarchived sheets or `full' to display archived and
unarchived sheets.
usage: t display [--ids] [--start DATE] [--end DATE] [--format FMT] [SHEET | all | full]
@@ -104,11 +106,13 @@
usage: t today [--ids] [--format FMT] [SHEET | all]
* yesterday - Shortcut for display with start and end dates as the day before the current day
usage: t yesterday [--ids] [--format FMT] [SHEET | all]
- * week - Shortcut for display with start date set to monday of this week.
+ * week - Shortcut for display with start date set to a day of this week.
+ The default start of the week is Monday.
+.
usage: t week [--ids] [--end DATE] [--format FMT] [SHEET | all]
* month - Shortcut for display with start date set to the beginning of either
this month or a specified month.
usage: t month [--ids] [--start MONTH] [--format FMT] [SHEET | all]
@@ -441,10 +445,16 @@
args['-e'] = yesterday
display
end
def week
- args['-s'] = Date.today.wday == 1 ? Date.today.to_s : Date.parse(Chronic.parse(%q(last monday)).to_s).to_s
+ d = Chronic.parse( args['-s'] || Date.today )
+
+ today = Date.new( d.year, d.month, d.day )
+ end_of_week = today + 6
+ last_week_start = Date.parse(Chronic.parse('last '.concat(Config['week_start']).to_s, :now => today).to_s)
+ args['-s'] = today.wday == Date.parse(Config['week_start']).wday ? today.to_s : last_week_start.to_s
+ args['-e'] = end_of_week.to_s
display
end
def month
d = Chronic.parse( args['-s'] || Date.today )