aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-08-11 18:59:38 -0400
committerPaul Duncan <pabs@pablotron.org>2016-08-11 18:59:38 -0400
commit91b423d3bb726c5ab30dbd24b50d4414aac3af41 (patch)
tree92ee11c0163a63381fd3031f5672deb6bd6662df
parent36f59f798104e3f01c4f3815401d809809e4859c (diff)
downloadzip-crystal-91b423d3bb726c5ab30dbd24b50d4414aac3af41.tar.bz2
zip-crystal-91b423d3bb726c5ab30dbd24b50d4414aac3af41.zip
move timehelper down
-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