Sha256: bfdcadfc2f1fef780ab807b28441dc5eda29508c49c3628c2bd794d2081999c6

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 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)

    t.strftime('%Y-%m-%d %H:%M:%S') + (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

1 entries across 1 versions & 1 rubygems

Version Path
fugit-0.9.6 lib/fugit/misc.rb