[Libreoffice-commits] core.git: 5 commits - basic/source include/osl include/tools oox/source package/source sal/osl sdext/source ucb/source
Lionel Elie Mamane
lionel at mamane.lu
Fri Jul 5 03:21:51 PDT 2013
basic/source/runtime/methods.cxx | 2 +-
include/osl/time.h | 10 +++++-----
include/tools/date.hxx | 1 +
oox/source/docprop/docprophandler.cxx | 2 +-
package/source/zipapi/ZipOutputStream.cxx | 17 +++++++++++++++--
sal/osl/unx/time.c | 13 +++++--------
sal/osl/w32/time.c | 8 ++++----
sdext/source/presenter/PresenterToolBar.cxx | 2 +-
ucb/source/ucp/webdav-neon/DateTimeHelper.cxx | 4 ++--
ucb/source/ucp/webdav/DateTimeHelper.cxx | 4 ++--
10 files changed, 37 insertions(+), 26 deletions(-)
New commits:
commit 4d220882b46d5f8edd4d09e5f66722cd296a092e
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Fri Jul 5 12:16:34 2013 +0200
hair splitting on years in dates in ZIP structure
Change-Id: I9d7a6436e3df75eff592d19dcaca0f655ebf2160
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index 7b2ae4f..22cc0b3 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) |
commit 6e82772db5ade43fc9f4f7181303264d2748d2a1
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Fri Jul 5 12:14:46 2013 +0200
TODO note for future *internal* API change
Signed year so that ~all our date types have about the same capacities.
Change-Id: Iab8a66bee0eb22ffd04608c345302218094e53a7
diff --git a/include/tools/date.hxx b/include/tools/date.hxx
index 5b451a3..87ba277 100644
--- a/include/tools/date.hxx
+++ b/include/tools/date.hxx
@@ -27,6 +27,7 @@ class ResId;
enum DayOfWeek { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
SATURDAY, SUNDAY };
+// TODO FIXME: make it handle signed year?
class TOOLS_DLLPUBLIC SAL_WARN_UNUSED Date
{
private:
commit fa6ce5a6e8c35430977857477fc09f6a03698e63
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Fri Jul 5 12:13:36 2013 +0200
API change: osl/time.h take const pointers where appropriate
Should be backwards-compatible...
Change-Id: I6b04bec2c032ff8c57a1b5192b2d3962dcc96c84
diff --git a/include/osl/time.h b/include/osl/time.h
index 6bb48f2..484adb0 100644
--- a/include/osl/time.h
+++ b/include/osl/time.h
@@ -111,7 +111,7 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTime(
@return sal_False if any error occurs else sal_True.
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getDateTimeFromTimeValue(
- TimeValue* pTimeVal, oslDateTime* pDateTime );
+ const TimeValue* pTimeVal, oslDateTime* pDateTime );
/** Get the GMT from a oslDateTime and fill a TimeValue
@@ -121,7 +121,7 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getDateTimeFromTimeValue(
@return sal_False if any error occurs else sal_True.
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getTimeValueFromDateTime(
- oslDateTime* pDateTime, TimeValue* pTimeVal );
+ const oslDateTime* pDateTime, TimeValue* pTimeVal );
/** Convert GMT to local time
@@ -131,7 +131,7 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getTimeValueFromDateTime(
@return sal_False if any error occurs else sal_True.
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime(
- TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
+ const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
/** Convert local time to GMT
@@ -141,7 +141,7 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime(
@return sal_False if any error occurs else sal_True.
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime(
- TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
+ const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
/** Get the value of the global timer
diff --git a/sal/osl/unx/time.c b/sal/osl/unx/time.c
index d038f46..24947b1 100644
--- a/sal/osl/unx/time.c
+++ b/sal/osl/unx/time.c
@@ -92,7 +92,7 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* tv)
* osl_getDateTimeFromTimeValue
*-------------------------------------------------*/
-sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime* pDateTime )
+sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( const TimeValue* pTimeVal, oslDateTime* pDateTime )
{
struct tm *pSystemTime;
struct tm tmBuf;
@@ -126,7 +126,7 @@ sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime
* osl_getTimeValueFromDateTime
*--------------------------------------------------*/
-sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValue* pTimeVal )
+sal_Bool SAL_CALL osl_getTimeValueFromDateTime( const oslDateTime* pDateTime, TimeValue* pTimeVal )
{
struct tm aTime;
time_t nSeconds;
@@ -193,7 +193,7 @@ sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValu
* osl_getLocalTimeFromSystemTime
*--------------------------------------------------*/
-sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal )
+sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal )
{
struct tm *pLocalTime;
struct tm tmBuf;
@@ -230,7 +230,7 @@ sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, Tim
* osl_getSystemTimeFromLocalTime
*--------------------------------------------------*/
-sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal )
+sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal )
{
struct tm *pLocalTime;
struct tm tmBuf;
diff --git a/sal/osl/w32/time.c b/sal/osl/w32/time.c
index fc8855b..52fe8ac 100644
--- a/sal/osl/w32/time.c
+++ b/sal/osl/w32/time.c
@@ -65,7 +65,7 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal)
// osl_getDateTimeFromTimeValue
//--------------------------------------------------
-sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime* pDateTime )
+sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( const TimeValue* pTimeVal, oslDateTime* pDateTime )
{
FILETIME aFileTime;
SYSTEMTIME aSystemTime;
@@ -95,7 +95,7 @@ sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime
// osl_getTimeValueFromDateTime
//--------------------------------------------------
-sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValue* pTimeVal )
+sal_Bool SAL_CALL osl_getTimeValueFromDateTime( const oslDateTime* pDateTime, TimeValue* pTimeVal )
{
FILETIME aFileTime;
SYSTEMTIME aSystemTime;
@@ -126,7 +126,7 @@ sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValu
// osl_getLocalTimeFromSystemTime
//--------------------------------------------------
-sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal )
+sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal )
{
TIME_ZONE_INFORMATION aTimeZoneInformation;
DWORD Success;
@@ -157,7 +157,7 @@ sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, Tim
// osl_getSystemTimeFromLocalTime
//--------------------------------------------------
-sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal )
+sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal )
{
TIME_ZONE_INFORMATION aTimeZoneInformation;
DWORD Success;
diff --git a/sdext/source/presenter/PresenterToolBar.cxx b/sdext/source/presenter/PresenterToolBar.cxx
index ce5c61f..e5d7efe 100644
--- a/sdext/source/presenter/PresenterToolBar.cxx
+++ b/sdext/source/presenter/PresenterToolBar.cxx
@@ -1928,7 +1928,7 @@ PresentationTimeLabel::PresentationTimeLabel (
void PresentationTimeLabel::TimeHasChanged (const oslDateTime& rCurrentTime)
{
TimeValue aCurrentTimeValue;
- if (osl_getTimeValueFromDateTime(const_cast<oslDateTime*>(&rCurrentTime), &aCurrentTimeValue))
+ if (osl_getTimeValueFromDateTime(&rCurrentTime, &aCurrentTimeValue))
{
if (maStartTimeValue.Seconds==0 && maStartTimeValue.Nanosec==0)
{
commit 8db392f1be4d6dac0da0fb35b5735e7c27c346cc
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Fri Jul 5 12:11:42 2013 +0200
API change: oslDateTime signed year
Change-Id: Ic4f1e424b130fd2ccca379adbe0a66836b6cac41
diff --git a/include/osl/time.h b/include/osl/time.h
index 4be9e72..6bb48f2 100644
--- a/include/osl/time.h
+++ b/include/osl/time.h
@@ -92,7 +92,7 @@ typedef struct _oslDateTime
/*----------------------------------------------------------------------*/
/** is the year.
*/
- sal_uInt16 Year;
+ sal_Int16 Year;
} oslDateTime;
diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx
index 92a7d49..467151d 100644
--- a/oox/source/docprop/docprophandler.cxx
+++ b/oox/source/docprop/docprophandler.cxx
@@ -98,7 +98,7 @@ util::DateTime OOXMLDocPropHandler::GetDateTimeFromW3CDTF( const OUString& aChar
sal_Int32 nLen = aChars.getLength();
if ( nLen >= 4 )
{
- aOslDTime.Year = (sal_uInt16)aChars.copy( 0, 4 ).toInt32();
+ aOslDTime.Year = (sal_Int16)aChars.copy( 0, 4 ).toInt32();
if ( nLen >= 7 && aChars.getStr()[4] == (sal_Unicode)'-' )
{
diff --git a/sal/osl/unx/time.c b/sal/osl/unx/time.c
index b71dd7d..d038f46 100644
--- a/sal/osl/unx/time.c
+++ b/sal/osl/unx/time.c
@@ -143,10 +143,7 @@ sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValu
else
return sal_False;
- if ( pDateTime->Year >= 1900 )
- aTime.tm_year = pDateTime->Year - 1900;
- else
- return sal_False;
+ aTime.tm_year = pDateTime->Year - 1900;
aTime.tm_isdst = -1;
aTime.tm_wday = 0;
diff --git a/ucb/source/ucp/webdav-neon/DateTimeHelper.cxx b/ucb/source/ucp/webdav-neon/DateTimeHelper.cxx
index 4bf2ea8..ce99c2d 100644
--- a/ucb/source/ucp/webdav-neon/DateTimeHelper.cxx
+++ b/ucb/source/ucp/webdav-neon/DateTimeHelper.cxx
@@ -89,7 +89,7 @@ bool DateTimeHelper::ISO8601_To_DateTime (const OUString& s,
aDateTime.Day = sal::static_int_cast< sal_uInt16 >(day); // 1-31
aDateTime.DayOfWeek = 0; // 0-6, 0 = Sunday
aDateTime.Month = sal::static_int_cast< sal_uInt16 >(month); // 1-12
- aDateTime.Year = sal::static_int_cast< sal_uInt16 >(year);
+ aDateTime.Year = sal::static_int_cast< sal_Int16 >(year);
TimeValue aTimeValue;
if ( osl_getTimeValueFromDateTime( &aDateTime, &aTimeValue ) )
@@ -206,7 +206,7 @@ bool DateTimeHelper::RFC2068_To_DateTime (const OUString& s,
aDateTime.DayOfWeek = 0; //dayofweek; // 0-6, 0 = Sunday
aDateTime.Month = sal::static_int_cast< sal_uInt16 >(month);
// 1-12
- aDateTime.Year = sal::static_int_cast< sal_uInt16 >(year);
+ aDateTime.Year = sal::static_int_cast< sal_Int16 >(year);
TimeValue aTimeValue;
if ( osl_getTimeValueFromDateTime( &aDateTime,
diff --git a/ucb/source/ucp/webdav/DateTimeHelper.cxx b/ucb/source/ucp/webdav/DateTimeHelper.cxx
index c4ccbca..7ca9a3d 100644
--- a/ucb/source/ucp/webdav/DateTimeHelper.cxx
+++ b/ucb/source/ucp/webdav/DateTimeHelper.cxx
@@ -79,7 +79,7 @@ bool DateTimeHelper::ISO8601_To_DateTime (const OUString& s,
aDateTime.Day = sal::static_int_cast< sal_uInt16 >(day); // 1-31
aDateTime.DayOfWeek = 0; // 0-6, 0 = Sunday
aDateTime.Month = sal::static_int_cast< sal_uInt16 >(month); // 1-12
- aDateTime.Year = sal::static_int_cast< sal_uInt16 >(year);
+ aDateTime.Year = sal::static_int_cast< sal_Int16 >(year);
TimeValue aTimeValue;
if ( osl_getTimeValueFromDateTime( &aDateTime, &aTimeValue ) )
@@ -218,7 +218,7 @@ bool DateTimeHelper::RFC2068_To_DateTime (const OUString& s,
aDateTime.DayOfWeek = 0; //dayofweek; // 0-6, 0 = Sunday
aDateTime.Month = sal::static_int_cast< sal_uInt16 >(month);
// 1-12
- aDateTime.Year = sal::static_int_cast< sal_uInt16 >(year);
+ aDateTime.Year = sal::static_int_cast< sal_Int16 >(year);
TimeValue aTimeValue;
if ( osl_getTimeValueFromDateTime( &aDateTime,
commit e436c491887636aee32a019ea3ecc26c63ecd899
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Fri Jul 5 12:00:18 2013 +0200
fixup nanosecond precision
This was broken before...
Time used to take centiseconds, so the nanoseconds should have been *divided* by 10^7 for conversion.
Now Time takes straight nanoseconds, so no conversion necessary.
Change-Id: Ibac3eeca7020c5d8c5ff4be3e7617fac26ee8180
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 1e49c1d..1ee75dc 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -3095,7 +3095,7 @@ RTLFUNC(FileDateTime)
oslDateTime aDT;
osl_getDateTimeFromTimeValue( &aTimeVal, &aDT );
- aTime = Time( aDT.Hours, aDT.Minutes, aDT.Seconds, 10000000*aDT.NanoSeconds );
+ aTime = Time( aDT.Hours, aDT.Minutes, aDT.Seconds, aDT.NanoSeconds );
aDate = Date( aDT.Day, aDT.Month, aDT.Year );
}
More information about the Libreoffice-commits
mailing list