Skip to content

Commit

Permalink
♻️ Use Time#strptime directly from decode_time
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Nov 7, 2023
1 parent 599f7fe commit e269e9c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/net/imap/data_encoding.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "date"
require "time"

require_relative "errors"

Expand Down Expand Up @@ -121,7 +122,10 @@ def self.decode_datetime(string)
#
# Same as +decode_datetime+, but returning a Time instead.
def self.decode_time(string)
decode_datetime(string).to_time
unless string.start_with?(?") && string.end_with?(?")
string = '"%s"' % [string]
end
Time.strptime(string, STRFTIME)
end

class << self
Expand Down

0 comments on commit e269e9c

Please sign in to comment.