pub enum Compression {
Stored // No compression (method 0)
Deflate // DEFLATE compression (method 8)
// Future: Bzip2, LZMA, etc.
} derive(Eq, Show)pub fn Compression::from_int(method : Int) -> Compression
pub fn Compression::to_int(self : Compression) -> Intpub let dos_epoch : Ptime // 1980-01-01 00:00:00 UTCpub fn fpath_ensure_unix(path : Fpath) -> Fpathpub fn fpath_ensure_directoryness(path : Fpath) -> Fpathpub fn fpath_sanitize(path : Fpath) -> Fpath///|
test {
// Create from ZIP method code
let compression = @types.Compression::from_int(8) // DEFLATE
// Convert to method code
let method_code = compression.to_int()
@json.inspect(method_code, content=8)
// Test stored compression
let stored = @types.Compression::from_int(0)
@json.inspect(stored.to_int(), content=0)
}// Get current time as POSIX timestamp
let now : Ptime = current_time()
// Convert to DOS format for ZIP
let (dos_date, dos_time) = ptime_to_dos_date_time(now)
// Store in ZIP file...
// Later, read from ZIP
let mtime = ptime_of_dos_date_time(dos_date, dos_time)
println("Modified: \{ptime_format(mtime)}")
// Output: "Modified: 2025-10-02 14:30:45"let ((year, month, day), (hour, minute, second)) = ptime_to_date_time(now)
println("\{year}-\{month}-\{day} \{hour}:\{minute}:\{second}")// Normalize Windows path
let path = fpath_ensure_unix("dir\\subdir\\file.txt")
// Result: "dir/subdir/file.txt"
// Ensure directory
let dir = fpath_ensure_directoryness("mydir")
// Result: "mydir/"
// Sanitize path
let clean = fpath_sanitize("dir//subdir/./file.txt")
// Result: "dir/subdir/file.txt"Bits 15-9: Year (0 = 1980, 127 = 2107)
Bits 8-5: Month (1-12)
Bits 4-0: Day (1-31)Bits 15-11: Hour (0-23)
Bits 10-5: Minute (0-59)
Bits 4-0: Second / 2 (0-29, representing 0-58 seconds)// October 2, 2025, 14:30:45
// DOS Date: (2025-1980) << 9 | 10 << 5 | 2 = 0x5A82
// DOS Time: 14 << 11 | 30 << 5 | (45/2) = 0x73D6
let dos_date = 0x5A82
let dos_time = 0x73D6
let ptime = ptime_of_dos_date_time(dos_date, dos_time)
println(ptime_format(ptime))
// Output: "2025-10-02 14:30:44" (45 seconds rounded down to 44)moon test typesInstall
Download zip