Class: Rbnotes::Commands::Builtins::Stamp

Inherits:
Command
  • Object
show all
Defined in:
lib/rbnotes/commands.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



168
169
170
# File 'lib/rbnotes/commands.rb', line 168

def description
  "Convert a time string into a timestamp string"
end

#execute(args, _) ⇒ Object



172
173
174
175
176
177
178
179
180
# File 'lib/rbnotes/commands.rb', line 172

def execute(args, _)
  time_str = args.shift
  unless time_str.nil?
    puts Textrepo::Timestamp.new(::Time.parse(time_str)).to_s
  else
    puts "not specified TIME_STR"
    super
  end
end

#helpObject



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/rbnotes/commands.rb', line 182

def help
  puts <<STAMP
usage:
    #{Rbnotes::NAME} stamp

Convert a given time string into a timestamp string.  The timestamp
string could be used as an argument of some rbnotes commands, such
"show".  Here is short example of conversion:

    "2020-11-06 16:51:15" -> "20201106165115"
    "2020-11-06"          -> "20201106000000"
    "20201106"            -> "20201106000000"
    "2020-11-06 16"       -> "20201106160000"
    "2020-11-06 16:51"    -> "20201106165100"
STAMP
end