Skip to content

Commit e269e9c

Browse files
committed
♻️ Use Time#strptime directly from decode_time
1 parent 599f7fe commit e269e9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/net/imap/data_encoding.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "date"
4+
require "time"
45

56
require_relative "errors"
67

@@ -121,7 +122,10 @@ def self.decode_datetime(string)
121122
#
122123
# Same as +decode_datetime+, but returning a Time instead.
123124
def self.decode_time(string)
124-
decode_datetime(string).to_time
125+
unless string.start_with?(?") && string.end_with?(?")
126+
string = '"%s"' % [string]
127+
end
128+
Time.strptime(string, STRFTIME)
125129
end
126130

127131
class << self

0 commit comments

Comments
 (0)