Skip to content

Commit

Permalink
Merge 2e64cdd into 2eac3d6
Browse files Browse the repository at this point in the history
  • Loading branch information
tcaddy committed Jul 17, 2018
2 parents 2eac3d6 + 2e64cdd commit 8705c61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
7 changes: 0 additions & 7 deletions lib/gmail.rb
Expand Up @@ -8,13 +8,6 @@
require "smtp_tls"
end

class Object
def to_imap_date
date = respond_to?(:utc) ? utc.to_s : to_s
Date.parse(date).strftime("%d-%b-%Y")
end
end

module Gmail
autoload :Version, "gmail/version"
autoload :Client, "gmail/client"
Expand Down
4 changes: 2 additions & 2 deletions lib/gmail/mailbox.rb
Expand Up @@ -32,8 +32,8 @@ def fetch_uids(*args)
search = MAILBOX_ALIASES[args.shift].dup
opts = args.first.is_a?(Hash) ? args.first : {}

opts[:after] and search.concat ['SINCE', opts[:after].to_imap_date]
opts[:before] and search.concat ['BEFORE', opts[:before].to_imap_date]
opts[:after] and search.concat ['SINCE', Net::IMAP.format_date(opts[:after])]
opts[:before] and search.concat ['BEFORE', Net::IMAP.format_date(opts[:before])]
opts[:on] and search.concat ['ON', opts[:on].to_imap_date]
opts[:from] and search.concat ['FROM', opts[:from]]
opts[:to] and search.concat ['TO', opts[:to]]
Expand Down
3 changes: 2 additions & 1 deletion spec/gmail_spec.rb
@@ -1,8 +1,9 @@
require 'spec_helper'
require 'net/imap'

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

%w[new new!].each do |method|
Expand Down

0 comments on commit 8705c61

Please sign in to comment.