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 <<TIME
usage:
    #{Rbnotes::NAME} time

Convert a given timestamp string into a time string.  Here is short
example of conversion:

    "20201106165115" -> "2020-11-06 16:51:15 +0900"
    "202011061651"   -> "2020-11-06 16:51:00 +0900"
    "2020110616"     -> "2020-11-06 16:00:00 +0900"
    "20201106"       -> "2020-11-06 00:00:00 +0900"
TIME
end