lib/active_shipping/carrier.rb in active_shipping-1.7.3 vs lib/active_shipping/carrier.rb in active_shipping-1.8.0
- old
+ new
@@ -70,12 +70,12 @@
# Cancels a shipment with a carrier.
#
# @note Override with whatever you need to cancel a shipping label
#
- # @param shipment_id [String] The unique identifier of the shipment to cancel.
- # This can be shipment_id or tracking number depending on carrier. Up to you and
+ # @param shipment_id [String] The unique identifier of the shipment to cancel.
+ # This can be shipment_id or tracking number depending on carrier. Up to you and
# the carrier
# @param options [Hash] Carrier-specific parameters.
# @return [ActiveShipping::ShipmentResponse] The response from the carrier. This
# response in most cases has a cancellation id.
def cancel_shipment(shipment_id, options = {})
@@ -160,14 +160,17 @@
# @param days [Integer] The number of business days from now.
# @return [DateTime] A timestamp, the provided number of business days in the future.
def timestamp_from_business_day(days)
return unless days
date = DateTime.now.utc
+
days.times do
- begin
- date = date + 1
- end while [0, 6].include?(date.wday)
+ date += 1.day
+
+ date += 2.days if date.saturday?
+ date += 1.day if date.sunday?
end
- date
+
+ date.to_datetime
end
end
end