Sha256: 5ee571810dcb4086793eef2dc7c0983d5fb53cb16d551033e18e8bddc9059999

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

require "time"

class Time                           # :nodoc:
  IMAPDATE     = "%d-%b-%Y"          # :nodoc:
  IMAPDATETIME = "%d-%b-%Y %H:%M %Z" # :nodoc:

  ##
  # Parse an IMAP date formatted string into a Time.

  def self.imapdate str
    Time.strptime str, IMAPDATE
  end

  ##
  # Parse an IMAP datetime formatted string into a Time.

  def self.imapdatetime str
    Time.strptime str, IMAPDATETIME
  end

  ##
  # Formats this Time as an IMAP-style date.

  def imapdate
    strftime IMAPDATE
  end

  ##
  # Formats this Time as an IMAP-style datetime.
  #
  # RFC 2060 doesn't specify the format of its times.  Unfortunately it is
  # almost but not quite RFC 822 compliant.
  #--
  # Go Mr. Leatherpants!

  def imapdatetime
    strftime IMAPDATETIME
  end

  ##
  # Format a date into YYYY-MM, common for mailbox extensions.

  def yyyy_mm
    strftime("%Y-%m")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
imap_processor-1.8.1 lib/net/imap/date.rb
imap_processor-1.8.0 lib/net/imap/date.rb