summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zip.cr72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/zip.cr b/src/zip.cr
index 4223238..587ec68 100644
--- a/src/zip.cr
+++ b/src/zip.cr
@@ -303,42 +303,6 @@ module Zip
end
#
- # Helper methods for converting to and from `Time` objects.
- #
- module TimeHelper
- #
- # Convert given `Time` to a DOS-style datetime, write the result to
- # the given IO, and return the number of bytes written.
- #
- private def write_time(io : IO, time : Time) : UInt32
- year = Math.max(1980, time.year) - 1980
-
- # convert to dos timestamp
- ((
- (year << 25) | (time.month << 21) | (time.day << 16) |
- (time.hour << 11) | (time.minute << 5) | (time.second >> 1)
- ) & UInt32::MAX).to_u32.to_io(io, LE)
-
- # return number of bytes written
- 4_u32
- end
-
- #
- # Convert given DOS datetime to a `Time` object.
- #
- private def from_dos_time(v : UInt32) : Time
- Time.new(
- year: (v >> 25) + 1980,
- month: (v >> 21) & 0b0000_1111,
- day: (v >> 16) & 0b0001_1111,
- hour: (v >> 11) & 0b0001_1111,
- minute: (v >> 5) & 0b0011_1111,
- second: (v << 1) & 0b0011_1110,
- )
- end
- end
-
- #
# Version identifier used to identify the version needed to extract a
# given file and to indicate the format of the external file
# attributes.
@@ -419,6 +383,42 @@ module Zip
end
#
+ # Helper methods for converting to and from `Time` objects.
+ #
+ module TimeHelper
+ #
+ # Convert given `Time` to a DOS-style datetime, write the result to
+ # the given IO, and return the number of bytes written.
+ #
+ private def write_time(io : IO, time : Time) : UInt32
+ year = Math.max(1980, time.year) - 1980
+
+ # convert to dos timestamp
+ ((
+ (year << 25) | (time.month << 21) | (time.day << 16) |
+ (time.hour << 11) | (time.minute << 5) | (time.second >> 1)
+ ) & UInt32::MAX).to_u32.to_io(io, LE)
+
+ # return number of bytes written
+ 4_u32
+ end
+
+ #
+ # Convert given DOS datetime to a `Time` object.
+ #
+ private def from_dos_time(v : UInt32) : Time
+ Time.new(
+ year: (v >> 25) + 1980,
+ month: (v >> 21) & 0b0000_1111,
+ day: (v >> 16) & 0b0001_1111,
+ hour: (v >> 11) & 0b0001_1111,
+ minute: (v >> 5) & 0b0011_1111,
+ second: (v << 1) & 0b0011_1110,
+ )
+ end
+ end
+
+ #
# Helper methods for reading and writing uncompressed data.
#
module NoneCompressionHelper