summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-07-05 12:16:34 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2013-07-05 12:22:04 +0200
commit4d220882b46d5f8edd4d09e5f66722cd296a092e (patch)
tree0cfd2661b5bb5fabcfd086adf309212bb1b73bd5 /package
parent6e82772db5ade43fc9f4f7181303264d2748d2a1 (diff)
hair splitting on years in dates in ZIP structure
Change-Id: I9d7a6436e3df75eff592d19dcaca0f655ebf2160
Diffstat (limited to 'package')
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index 7b2ae4ffe543..22cc0b320e00 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -450,12 +450,25 @@ sal_uInt32 ZipOutputStream::getCurrentDosTime( )
osl_getSystemTime ( &aTimeValue );
osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime);
+ // at year 2108, there is an overflow
+ // -> some decision needs to be made
+ // how to handle the ZIP file format (just overflow?)
+
+ // if the current system time is before 1980,
+ // then the time traveller will have to make a decision
+ // how to handle the ZIP file format before it is invented
+ // (just underflow?)
+
+ assert(aDateTime.Year > 1980 && aDateTime.Year < 2108);
+
sal_uInt32 nYear = static_cast <sal_uInt32> (aDateTime.Year);
- if (nYear>1980)
+ if (nYear>=1980)
nYear-=1980;
- else if (nYear>80)
+ else if (nYear>=80)
+ {
nYear-=80;
+ }
sal_uInt32 nResult = static_cast < sal_uInt32>( ( ( ( aDateTime.Day) +
( 32 * (aDateTime.Month)) +
( 512 * nYear ) ) << 16) |