Skip to content

Commit 8a3982f

Browse files
tcaddyjohnnyshields
authored andcommitted
Use Net::IMAP.format_date (#260)
1 parent 2eac3d6 commit 8a3982f

3 files changed

Lines changed: 4 additions & 10 deletions

File tree

lib/gmail.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
require "smtp_tls"
99
end
1010

11-
class Object
12-
def to_imap_date
13-
date = respond_to?(:utc) ? utc.to_s : to_s
14-
Date.parse(date).strftime("%d-%b-%Y")
15-
end
16-
end
17-
1811
module Gmail
1912
autoload :Version, "gmail/version"
2013
autoload :Client, "gmail/client"

lib/gmail/mailbox.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def fetch_uids(*args)
3232
search = MAILBOX_ALIASES[args.shift].dup
3333
opts = args.first.is_a?(Hash) ? args.first : {}
3434

35-
opts[:after] and search.concat ['SINCE', opts[:after].to_imap_date]
36-
opts[:before] and search.concat ['BEFORE', opts[:before].to_imap_date]
35+
opts[:after] and search.concat ['SINCE', Net::IMAP.format_date(opts[:after])]
36+
opts[:before] and search.concat ['BEFORE', Net::IMAP.format_date(opts[:before])]
3737
opts[:on] and search.concat ['ON', opts[:on].to_imap_date]
3838
opts[:from] and search.concat ['FROM', opts[:from]]
3939
opts[:to] and search.concat ['TO', opts[:to]]

spec/gmail_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require 'spec_helper'
2+
require 'net/imap'
23

34
describe Gmail do
45
it "should be able to convert itself to IMAP date format" do
5-
expect("20-12-1988".to_imap_date).to eq("20-Dec-1988")
6+
expect(Net::IMAP.format_date(Date.new(1988, 12, 20))).to eq("20-Dec-1988")
67
end
78

89
%w[new new!].each do |method|

0 commit comments

Comments
 (0)