rubyshelltools 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,10 +51,31 @@ module RST
51
51
  param
52
52
  elsif param =~ /today/i || param.nil?
53
53
  Date.today
54
- else
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
@@ -3,7 +3,7 @@ require 'logger'
3
3
  # # Ruby Shell Tools Top-level file
4
4
  module RST
5
5
  # Gem-version
6
- VERSION = '0.0.4'
6
+ VERSION = '0.0.5'
7
7
 
8
8
  # Path to the docs used by the software
9
9
  DOCS = File.expand_path('../assets/docs', __FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyshelltools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: