Class: Rbnotes::Commands::Builtins::Time

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

Instance Method Summary collapse

Instance Method Details

#descriptionObject



201
202
203
# File 'lib/rbnotes/commands.rb', line 201

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

#execute(args, _) ⇒ Object



205
206
207
208
209
210
211
212
213
# File 'lib/rbnotes/commands.rb', line 205

def execute(args, _)
  stamp = args.shift
  unless stamp.nil?
    puts ::Time.new(*Textrepo::Timestamp.split_stamp(stamp).map(&:to_i)).to_s
  else
    puts "not specified STAMP"
    super
  end
end

#helpObject



215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/rbnotes/commands.rb', line 215

def help
  puts "usage:\n    \#{Rbnotes::NAME} time\n\nConvert a given timestamp string into a time string.  Here is short\nexample of conversion:\n\n    \"20201106165115\" -> \"2020-11-06 16:51:15 +0900\"\n    \"202011061651\"   -> \"2020-11-06 16:51:00 +0900\"\n    \"2020110616\"     -> \"2020-11-06 16:00:00 +0900\"\n    \"20201106\"       -> \"2020-11-06 00:00:00 +0900\"\n"
end