Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/net/imap/date.rb

Overview

:nodoc:

Constant Summary collapse

IMAPDATE =

:nodoc:

"%d-%b-%Y"
IMAPDATETIME =

:nodoc:

"%d-%b-%Y %H:%M %Z"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.imapdate(str) ⇒ Object

Parse an IMAP date formatted string into a Time.



10
11
12
# File 'lib/net/imap/date.rb', line 10

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

.imapdatetime(str) ⇒ Object

Parse an IMAP datetime formatted string into a Time.



17
18
19
# File 'lib/net/imap/date.rb', line 17

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

Instance Method Details

#imapdateObject

Formats this Time as an IMAP-style date.



24
25
26
# File 'lib/net/imap/date.rb', line 24

def imapdate
  strftime IMAPDATE
end

#imapdatetimeObject

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!



36
37
38
# File 'lib/net/imap/date.rb', line 36

def imapdatetime
  strftime IMAPDATETIME
end

#yyyy_mmObject

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



43
44
45
# File 'lib/net/imap/date.rb', line 43

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