Sha256: e64f32efaa9425f870f07862c4666c82105060ab9d85fbfa7d5ccb723b800d89

Contents?: true

Size: 611 Bytes

Versions: 5

Compression:

Stored size: 611 Bytes

Contents

module Fugit

  def self.isostamp(show_date, show_time, show_usec, time)

    t = time || Time.now
    s = StringIO.new

    s << t.strftime('%Y-%m-%d') if show_date
    s << t.strftime('T%H:%M:%S') if show_time
    s << sprintf('.%06d', t.usec) if show_time && show_usec
    s << 'Z' if show_time && time.utc?

    s.string
  end

  def self.time_to_s(t)

    isostamp(true, true, false, t)
  end

  def self.time_to_plain_s(t=Time.now, z=true)

    t.strftime('%Y-%m-%d %H:%M:%S') + (z && t.utc? ? ' Z' : '')
  end

  def self.time_to_zone_s(t=Time.now)

    t.strftime('%Y-%m-%d %H:%M:%S %Z %z')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fugit-1.1.3 lib/fugit/misc.rb
fugit-1.1.2 lib/fugit/misc.rb
fugit-1.1.1 lib/fugit/misc.rb
fugit-1.1.0 lib/fugit/misc.rb
fugit-1.0.0 lib/fugit/misc.rb