module Fugit

def determine_type(s)

def determine_type(s)
  case self.parse(s)
  when ::Fugit::Cron then 'cron'
  when ::Fugit::Duration then 'in'
  when ::Time, ::EtOrbi::EoTime then 'at'
  else nil
  end
end

def do_parse(s, opts={})

def do_parse(s, opts={})
  parse(s, opts) ||
  fail(ArgumentError.new("found no time information in #{s.inspect}"))
end

def do_parse_at(s); ::Fugit::At.do_parse(s); end

def do_parse_at(s); ::Fugit::At.do_parse(s); end

def do_parse_cron(s); ::Fugit::Cron.do_parse(s); end

def do_parse_cron(s); ::Fugit::Cron.do_parse(s); end

def do_parse_duration(s); ::Fugit::Duration.do_parse(s); end

def do_parse_duration(s); ::Fugit::Duration.do_parse(s); end

def do_parse_in(s); do_parse_duration(s); end

def do_parse_in(s); do_parse_duration(s); end

def do_parse_nat(s, opts={}); ::Fugit::Nat.do_parse(s, opts); end

def do_parse_nat(s, opts={}); ::Fugit::Nat.do_parse(s, opts); end

def isostamp(show_date, show_time, show_usec, time)

def 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 parse(s, opts={})

def parse(s, opts={})
  opts[:at] = opts[:in] if opts.has_key?(:in)
  (opts[:cron] != false && parse_cron(s)) ||
  (opts[:duration] != false && parse_duration(s)) ||
  (opts[:nat] != false && parse_nat(s, opts)) ||
  (opts[:at] != false && parse_at(s)) ||
  nil
end

def parse_at(s); ::Fugit::At.parse(s); end

def parse_at(s); ::Fugit::At.parse(s); end

def parse_cron(s); ::Fugit::Cron.parse(s); end

def parse_cron(s); ::Fugit::Cron.parse(s); end

def parse_duration(s); ::Fugit::Duration.parse(s); end

def parse_duration(s); ::Fugit::Duration.parse(s); end

def parse_in(s); parse_duration(s); end

def parse_in(s); parse_duration(s); end

def parse_nat(s, opts={}); ::Fugit::Nat.parse(s, opts); end

def parse_nat(s, opts={}); ::Fugit::Nat.parse(s, opts); end

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

def time_to_plain_s(t=Time.now, z=true)
  t.strftime('%Y-%m-%d %H:%M:%S') + (z && t.utc? ? ' Z' : '')
end

def time_to_s(t)

def time_to_s(t)
  isostamp(true, true, false, t)
end

def time_to_zone_s(t=Time.now)

def time_to_zone_s(t=Time.now)
  t.strftime('%Y-%m-%d %H:%M:%S %Z %z')
end