rubyshelltools 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/modules/calendar/calendar.rb +22 -1
- data/lib/rst.rb +13 -1
- data/rst.rb +1 -1
- metadata +1 -1
@@ -51,10 +51,31 @@ module RST
|
|
51
51
|
param
|
52
52
|
elsif param =~ /today/i || param.nil?
|
53
53
|
Date.today
|
54
|
-
|
54
|
+
elsif param =~ /\d+[wmd]/i
|
55
|
+
get_today_plus(param)
|
56
|
+
else
|
55
57
|
Date.parse(param)
|
56
58
|
end
|
57
59
|
end
|
60
|
+
|
61
|
+
# Get Today + param
|
62
|
+
# @param [String] param nDWM n=Number Day Weeks Months
|
63
|
+
def get_today_plus(param)
|
64
|
+
offset = 0
|
65
|
+
param.scan(/(\d+)([dwm])/i) do |count,unit|
|
66
|
+
offset = case unit[0].downcase
|
67
|
+
when 'd'
|
68
|
+
count.to_i.days
|
69
|
+
when 'w'
|
70
|
+
count.to_i.weeks
|
71
|
+
when 'm'
|
72
|
+
count.to_i.months
|
73
|
+
else
|
74
|
+
raise "Unknown unit #{unit}. Valid units are d,w,m or days,weeks,months"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
Date.parse( (Time.now + offset).to_s )
|
78
|
+
end
|
58
79
|
end
|
59
80
|
|
60
81
|
# Calendar has a name and will be stored in Persistent::DiskStore(CALENDAR_FILE)
|
data/lib/rst.rb
CHANGED
@@ -96,7 +96,11 @@ module RST
|
|
96
96
|
@options[:name] = name
|
97
97
|
end
|
98
98
|
|
99
|
-
opts.on('-e', '--new-event DATE,STRING', Array, 'Add an event') do |date,name|
|
99
|
+
opts.on('-e', '--new-event [DATE,]STRING', Array, 'Add an event') do |date,name|
|
100
|
+
if name.nil?
|
101
|
+
name = date
|
102
|
+
date = Date.today
|
103
|
+
end
|
100
104
|
@options[:new_event] = {date: date, label: name}
|
101
105
|
end
|
102
106
|
|
@@ -130,6 +134,14 @@ module RST
|
|
130
134
|
nil .......... no command. Interpret options only (useful in combination with -v)
|
131
135
|
ls ........... list directory and files
|
132
136
|
cal[endar] ... print a calendar --from --to
|
137
|
+
|
138
|
+
DATE-FORMATS FOR --new-event
|
139
|
+
ommit ........ today
|
140
|
+
today ........ today
|
141
|
+
yyyy-mm-dd
|
142
|
+
dd.mm.yyyy
|
143
|
+
mm/dd/yyyy
|
144
|
+
nDWM ......... today + n days, weeks, months eg 1w, 2d[ays], 1M[ONTH]
|
133
145
|
EOT
|
134
146
|
.gsub(/^\s+/,' ')
|
135
147
|
|
data/rst.rb
CHANGED