Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0606-Handle-seconds-in-zip-dos_date_time_from_d...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0606-Handle-seconds-in-zip-dos_date_time_from_datetime-1.patch of Package erlang
From 0e483bb07fda7e5e13aae274f7b84bfeb6ceb57d Mon Sep 17 00:00:00 2001 From: Ivan Sokolov <ivan-p-sokolov@ya.ru> Date: Tue, 27 Jun 2023 06:09:29 +0300 Subject: [PATCH] Handle seconds in `zip:dos_date_time_from_datetime/1` --- lib/stdlib/src/zip.erl | 3 +++ lib/stdlib/test/zip_SUITE.erl | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/stdlib/src/zip.erl b/lib/stdlib/src/zip.erl index 0809dbb492..4be9c78d04 100644 --- a/lib/stdlib/src/zip.erl +++ b/lib/stdlib/src/zip.erl @@ -1620,6 +1620,9 @@ dos_date_time_to_datetime(DosDate, DosTime) -> {{YearFrom1980+1980, Month, Day}, {Hour, Min, Sec}}. +dos_date_time_from_datetime(Seconds) when is_integer(Seconds) -> + DateTime = calendar:now_to_datetime({0, Seconds, 0}), + dos_date_time_from_datetime(DateTime); dos_date_time_from_datetime({{Year, Month, Day}, {Hour, Min, Sec}}) -> YearFrom1980 = Year-1980, <<DosTime:16>> = <<Hour:5, Min:6, Sec:5>>, diff --git a/lib/stdlib/test/zip_SUITE.erl b/lib/stdlib/test/zip_SUITE.erl index 97e5c660dd..3810c0362c 100644 --- a/lib/stdlib/test/zip_SUITE.erl +++ b/lib/stdlib/test/zip_SUITE.erl @@ -27,7 +27,8 @@ openzip_api/1, zip_api/1, open_leak/1, unzip_jar/1, unzip_traversal_exploit/1, compress_control/1, - foldl/1,fd_leak/1,unicode/1,test_zip_dir/1]). + foldl/1,fd_leak/1,unicode/1,test_zip_dir/1, + explicit_file_info/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("kernel/include/file.hrl"). @@ -40,7 +41,8 @@ all() -> unzip_to_binary, zip_to_binary, unzip_options, zip_options, list_dir_options, aliases, openzip_api, zip_api, open_leak, unzip_jar, compress_control, foldl, - unzip_traversal_exploit,fd_leak,unicode,test_zip_dir]. + unzip_traversal_exploit,fd_leak,unicode,test_zip_dir, + explicit_file_info]. groups() -> []. @@ -1054,3 +1056,10 @@ run_command(Command, Args) -> end end)(). +explicit_file_info(_Config) -> + Epoch = {{1980,1,1},{0,0,0}}, + FileInfo = #file_info{type=regular, size=0, mtime=Epoch}, + Files = [{"datetime", <<>>, FileInfo}, + {"seconds", <<>>, FileInfo#file_info{mtime=315532800}}], + {ok, _} = zip:zip("", Files, [memory]), + ok. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor