diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-09-08 13:35:55 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-09-08 13:35:55 +0000 |
commit | 38af9f501f95461b19fc8a0adca44b6b06446ef5 (patch) | |
tree | bf827f14b6cb4de8795abb4a45c9f540828b7593 | |
parent | 766d029fcf8cfaa63b981a37bbd8ed2d3910d411 (diff) |
INTEGRATION: CWS desktintgr02 (1.2.8); FILE MERGED
2004/08/18 06:41:51 deuce 1.2.8.1: Issue number: i32660, i32927, i32268
Submitted by: Gorden Lin {Gorden.Lin@Sun.com}
Reviewed by: Tino Rachui {Tino.Rachui@Sun.com}
-rw-r--r-- | shell/source/win32/shlxthandler/util/iso8601_converter.cxx | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx index ac508b194c63..18f6e883bd43 100644 --- a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx +++ b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: iso8601_converter.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: hr $ $Date: 2004-04-07 11:17:28 $ + * last change: $Author: hr $ $Date: 2004-09-08 14:35:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,10 @@ #include "internal/iso8601_converter.hxx" #endif +#ifndef UTILITIES_HXX_INCLUDED +#include "internal/utilities.hxx" +#endif + #include <sstream> #include <iomanip> @@ -71,17 +75,61 @@ represenation to the representation conforming to the current locale */ -std::wstring iso8601_date_to_local_date(const std::wstring& iso8601date) +std::wstring iso8601_date_to_local_date(const std::wstring& isoDate ) { - // expect YYYY-MM-DDThh:mm:ss - if (19 == iso8601date.length()) + const std::wstring CONST_SPACE(L" "); + ::std::wstring ws8601DateTime(isoDate); + + if ( ws8601DateTime.length() == 19 ) { - std::wstring date(iso8601date.substr(0, 10)); - std::wstring time(iso8601date.substr(11, 8)); - std::wstring separator(L", "); - return (date + separator + time); + //fill in the SYSTEMTIME structure; + std::string asDateTime = WStringToString( ws8601DateTime ); + SYSTEMTIME DateTime; + DateTime.wYear = ( unsigned short )strtol( asDateTime.substr( 0, 4 ).c_str(), NULL, 10 ); + DateTime.wMonth = ( unsigned short )strtol( asDateTime.substr( 5, 2 ).c_str(), NULL, 10 ); + DateTime.wDayOfWeek = 0; + DateTime.wDay = ( unsigned short )strtol( asDateTime.substr( 8, 2 ).c_str(), NULL, 10 ); + DateTime.wHour = ( unsigned short )strtol( asDateTime.substr( 11,2 ).c_str(), NULL, 10 ); + DateTime.wMinute = ( unsigned short )strtol( asDateTime.substr( 14,2 ).c_str(), NULL, 10 ); + DateTime.wSecond = ( unsigned short )strtol( asDateTime.substr( 17,2 ).c_str(), NULL, 10 ); + DateTime.wMilliseconds = 0; + + //get Date info from structure + WCHAR DateBuffer[ MAX_PATH ]; + int DateSize = GetDateFormatW( + LOCALE_SYSTEM_DEFAULT, + 0, + &DateTime, + NULL, + DateBuffer, + MAX_PATH ); + + if ( DateSize ) + ws8601DateTime.assign(DateBuffer); + else + ws8601DateTime = StringToWString( asDateTime ); + + //get Time info from structure + WCHAR TimeBuffer[ MAX_PATH ]; + + int TimeSize = GetTimeFormatW( + LOCALE_SYSTEM_DEFAULT, + 0, + &DateTime, + NULL, + TimeBuffer, + MAX_PATH ); + + if ( TimeSize ) + { + ws8601DateTime.append(L" "); + ws8601DateTime.append(TimeBuffer); + } + else + ws8601DateTime = StringToWString( asDateTime ); } - return iso8601date; + + return ws8601DateTime; } //------------------------------------ |