3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 /*@file: IntPresentationModelBase.cpp
20 *@brief: Defines the database/storage functions.
26 #include "IntPresentationModelBase.h"
29 const wchar_t* BOOKMARK_URL_TABLE = L"Bookmarks";
30 //const wchar_t* BOOKMARK_FOLDER_TABLE = L"BookmarkFolder";
31 const wchar_t* HISTORY_DATA_TABLE = L"History";
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::Io;
38 using namespace Tizen::Locales;
39 using namespace Tizen::System;
41 const int PresentationModelBase::MAX_DB_QUERY_SIZE = 21474836;
42 const int PresentationModelBase::QUERY_TYPE_LENGTH = 6;
44 PresentationModelBase::PresentationModelBase(void)
48 __pDbStatement = null;
49 __isBeginTransaction = false;
50 DB_FILE_PATH = L"/opt/usr/dbspace/.browser-history.db";
53 PresentationModelBase::~PresentationModelBase(void)
59 PresentationModelBase::Initialize(void)
69 PresentationModelBase::UnInitialize(void)
73 r = PresentationModelBase::CloseDb();
79 PresentationModelBase::OpenDb(void)
83 if (__pDataBase != null)
85 if (__pDbEnum != null)
90 if (__pDbStatement != null)
92 delete __pDbStatement;
93 __pDbStatement = null;
97 __pDataBase = new(std::nothrow) Database();
98 if (null == __pDataBase)
100 return E_OUT_OF_MEMORY;
102 String dbName = DB_FILE_PATH;
104 r = __pDataBase->Construct(dbName, true);
107 AppLogDebug("DB construction failed:%s", GetErrorMessage(r));
114 __isBeginTransaction = false;
115 if (File::IsFileExist(dbName))
117 r = InitializeDBTables();
129 PresentationModelBase::CloseDb(void)
131 if (__pDbEnum != null)
136 if (__pDbStatement != null)
138 delete __pDbStatement;
139 __pDbStatement = null;
141 if (__pDataBase != null)
147 __isBeginTransaction = false;
153 PresentationModelBase::CreateDBTables(BrowserDbTableTypes tableType)
155 result r = E_FAILURE;
157 int resultCount = -1;
159 if (DB_FILE_PATH.CompareTo(L"/opt/usr/dbspace/.internet_bookmark.db") == 0)
163 case DB_TYPE_BOOKMARKURLS:
165 query.Append(L"CREATE TABLE IF NOT EXISTS ");
166 query.Append(BOOKMARK_URL_TABLE);
167 //query.Append(L" ( ID INTEGER PRIMARY KEY AUTOINCREMENT, TITLE TEXT, URL TEXT, PARENT_BOOKMARK_ID INTEGER DEFAULT -1, CREATED_TIME DATETIME, MODIFIED_TIME DATETIME, ICON_PATH TEXT, FAVICON_ID INTEGER)");
168 query.Append(L" ( ID INTEGER PRIMARY KEY AUTOINCREMENT, TYPE INTEGER, PARENT INTEGER DEFAULT -1, ADDRESS TEXT, TITLE TEXT, CREATIONDATE DATETIME, SEQUENCE INTEGER, UPDATEDATE DATETIME, VISITDATE DATETIME, EDITABLE INTEGER, ACCESSACCOUNT INTEGER, FAVICON BLOB, FAVICON_LENGTH INTEGER, FAVICON_W INTEGER, FAVICON_H INTEGER, CREATED_DATE DATETIME, ACCOUNT_NAME TEXT, ACCOUNT_TYPE TEXT, THUMBNAIL BLOB, THUMBNAIL_LENGTH INTEGER, THUMBNAIL_W INTEGER, THUMBNAIL_H INTEGER, VERSION INTEGER, SYNC TEXT, TAG1 TEXT, TAG2 TEXT, TAG3 TEXT, TAG4 TEXT)");
172 case DB_TYPE_FAVICON:
174 query.Append(L"CREATE TABLE IF NOT EXISTS FaviconData ( ID INTEGER PRIMARY KEY AUTOINCREMENT, URL TEXT, FILE_PATH TEXT )");
179 AppLogDebug("PresentationModelBase::CreateDBTables: Table Type:%d is invalid", tableType);
184 else if(DB_FILE_PATH.CompareTo(L"/opt/usr/dbspace/.browser-history.db") == 0)
188 case DB_TYPE_HISTORYDATA:
190 query.Append(L"CREATE TABLE IF NOT EXISTS ");
191 query.Append(HISTORY_DATA_TABLE);
192 //query.Append(L" ( ID INTEGER PRIMARY KEY AUTOINCREMENT, TITLE TEXT, URL TEXT, VISITED_TIME DATETIME, ICON_PATH TEXT, FAVICON_ID INTEGER, THUMBNAIL_PATH TEXT)");
193 query.Append(L"(ID INTEGER PRIMARY KEY AUTOINCREMENT, ADDRESS TEXT, TITLE TEXT, COUNTER INTEGER, VISITDATE DATETIME, FAVICON BLOB, FAVICON_LENGTH INTEGER, FAVICON_W INTEGER, FAVICON_H INTEGER, SNAPSHOT BLOB, SNAPSHOT_STRIDE INTEGER, SNAPSHOT_W INTEGER, SNAPSHOT_H INTEGER)");
196 case DB_TYPE_FAVICON:
198 query.Append(L"CREATE TABLE IF NOT EXISTS FaviconData ( ID INTEGER PRIMARY KEY AUTOINCREMENT, URL TEXT, FILE_PATH TEXT )");
203 AppLogDebug("PresentationModelBase::CreateDBTables: Table Type:%d is invalid", tableType);
209 r = PresentationModelBase::ExecuteQuery(query, resultCount);
210 TryCatch(!IsFailed(r),,"PresentationModelBase::CreateDBTables query failed %s",GetErrorMessage(r));
216 PresentationModelBase::InitializeDBTables(void)
218 result r = E_FAILURE;
219 AppLog("DB_FILE_PATH :%ls", String(DB_FILE_PATH).GetPointer());
220 for (register int nDbTblIndex = DB_TYPE_INVALID + 1; nDbTblIndex < DB_TYPE_MAX; nDbTblIndex++)
222 r = CreateDBTables((BrowserDbTableTypes) nDbTblIndex);
223 TryCatch(!IsFailed(r),,"PresentationModelBase::InitializeDBTables failed %s",GetErrorMessage(r));
230 PresentationModelBase::DropDBTables(void)
232 result r = E_FAILURE;
234 int resultCount = -1;
236 for (register int tableIndex = DB_TYPE_INVALID + 1; tableIndex < DB_TYPE_MAX; tableIndex++)
240 case DB_TYPE_BOOKMARKURLS:
243 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS Bookmark");
246 /*case DB_TYPE_BOOKMARKFOLDERS:
249 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS BookmarkFolder");
253 case DB_TYPE_HISTORYDATA:
256 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS HistoryData");
260 case DB_TYPE_FAVICON:
263 query.Format(MAX_DB_QUERY_SIZE, L"DROP TABLE IF EXISTS FaviconData");
269 AppLogDebug("PresentationModelBase::CreateDBTables: Table Type:%d is invalid", tableIndex);
275 r = PresentationModelBase::ExecuteQuery(query, resultCount);
276 TryCatch( !IsFailed(r),,"PresentationModelBase::DropDBTables query failed %s",GetErrorMessage(r));
283 PresentationModelBase::ExecuteQuery(const String& formatQuery, int& count)
285 AppLogDebug("rahul Query: %ls", formatQuery.GetPointer());
287 result r = E_FAILURE;
290 if (__pDataBase == null)
292 return E_INIT_FAILED;
295 if (__pDbEnum != null)
301 if (__pDbStatement != null)
303 delete __pDbStatement;
304 __pDbStatement = null;
308 #if defined(FBK_DB_QUERY_LOG)
311 file.Construct(L"/Home/Query.txt", "a+", true);
312 file.Write(formatQuery);
313 file.Write(String("\r\n"));
317 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
320 if (queryType == "SELECT")
322 __pDbEnum = __pDataBase->QueryN(formatQuery);
326 AppLogException("Failed Database::QueryN(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
331 if (__pDbEnum != null)
333 while (__pDbEnum->MoveNext() == E_SUCCESS)
343 if (__isBeginTransaction == false &&
344 (queryType == L"INSERT" || queryType == L"UPDATE" || queryType == L"DELETE"))
346 r = __pDataBase->BeginTransaction();
349 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
353 __isBeginTransaction = true;
356 r = __pDataBase->ExecuteSql(formatQuery, false);
359 AppLogException("Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
370 PresentationModelBase::ExecuteBookmarkQuery(const Tizen::Base::String& formatQuery, int& count, BookmarkData& bookmark)
372 AppLogDebug("PresentationModelBase::ExecuteBookmarkQuery Query: %ls", formatQuery.GetPointer());
374 result r = E_FAILURE;
379 String bookmarkTitle = bookmark.GetBookmarkTitle();
380 bookmarkTitle.Replace(L"'", L"''");
381 String bookmarkUrl = bookmark.GetUrl();
382 bookmarkUrl.Replace(L"'", L"''");
384 PresentationModelBase::GetCurrentDateTime(dt);
386 if (__pDataBase == null)
388 return E_INIT_FAILED;
391 if (__pDbEnum != null)
397 if (__pDbStatement != null)
399 delete __pDbStatement;
400 __pDbStatement = null;
404 #if defined(FBK_DB_QUERY_LOG)
407 file.Construct(L"/Home/Query.txt", "a+", true);
408 file.Write(formatQuery);
409 file.Write(String("\r\n"));
413 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
416 if (queryType == "SELECT")
418 __pDbEnum = __pDataBase->QueryN(formatQuery);
422 AppLogException("Failed Database::QueryN(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
427 if (__pDbEnum != null)
429 while (__pDbEnum->MoveNext() == E_SUCCESS)
438 if (__isBeginTransaction == false && (queryType == L"INSERT" ))
440 r = __pDataBase->BeginTransaction();
443 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
447 __isBeginTransaction = true;
448 __pDbStatement = __pDataBase->CreateStatementN(formatQuery);
449 __pDbStatement->BindInt(0,bookmark.GetBookmarkType());
450 __pDbStatement->BindString(1,bookmark.GetParentId());
451 __pDbStatement->BindString(2,bookmarkUrl);
452 __pDbStatement->BindString(3,bookmarkTitle);
453 DateTimeFormatter *pFormatter = DateTimeFormatter::CreateDateFormatterN(DATE_TIME_STYLE_DEFAULT);
454 pFormatter->ApplyPattern(L"yyyy-mm-dd hh:mm:ss");
456 pFormatter->Format(dt, dateStr);
457 AppLog("DateStr: %ls", dateStr.GetPointer());
458 __pDbStatement->BindString(4,dateStr);
459 __pDbStatement->BindString(5,dateStr);
461 if(bookmark.GetFavIconBuffer() != null)
463 __pDbStatement->BindBlob(6,*(bookmark.GetFavIconBuffer()));
465 __pDbStatement->BindInt(7,bookmark.GetFavIconWidth());
466 __pDbStatement->BindInt(8,bookmark.GetFavIconHeight());
468 __pDataBase->ExecuteStatementN(*__pDbStatement);
470 if (IsFailed(GetLastResult()))
472 AppLog("PresentationModelBase::ExecuteBookmarkQuery Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
477 AppLog("PresentationModelBase::ExecuteBookmarkQuery success database");
480 else if (__isBeginTransaction == false && (queryType == L"UPDATE" || queryType == L"DELETE"))
482 r = __pDataBase->ExecuteSql(formatQuery, false);
485 AppLogException("Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
498 PresentationModelBase::ExecuteHistoryQuery(const Tizen::Base::String& formatQuery, int& nRowCount, History& history)
501 AppLogDebug("Query: %ls", formatQuery.GetPointer());
503 result r = E_FAILURE;
508 String historyTitle = history.GetHistoryTitle();
509 historyTitle.Replace(L"'", L"''");
511 String historyUrl = history.GetHistoryUrl();
512 historyUrl.Replace(L"'", L"''");
514 GetCurrentDateTime(date);
516 if (__pDataBase == null)
518 return E_INIT_FAILED;
521 if (__pDbEnum != null)
527 if (__pDbStatement != null)
529 delete __pDbStatement;
530 __pDbStatement = null;
533 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
536 if (queryType == "SELECT")
538 __pDbEnum = __pDataBase->QueryN(formatQuery);
542 AppLogException("Failed Database::QueryN(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
547 if (__pDbEnum != null)
549 while (__pDbEnum->MoveNext() == E_SUCCESS)
559 if (__isBeginTransaction == false && (queryType == L"INSERT"))
561 r = __pDataBase->BeginTransaction();
564 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
568 __isBeginTransaction = true;
569 __pDbStatement = __pDataBase->CreateStatementN(formatQuery);
570 if(GetLastResult() != E_SUCCESS)
572 AppLog("CreateStatementN error: %s", GetErrorMessage(GetLastResult()));
573 return GetLastResult();
575 __pDbStatement->BindString(0,historyUrl);
576 __pDbStatement->BindString(1,historyTitle);
578 String visitedTime = GetStringFromDate(date);
579 /*DateTimeFormatter *pFormatter = DateTimeFormatter::CreateDateFormatterN(DATE_TIME_STYLE_DEFAULT);
580 pFormatter->ApplyPattern(L"YYYY-MM-dd hh:mm:ss");
582 pFormatter->Format(date, dateStr);
583 AppLog("DateStr: %ls", dateStr.GetPointer());*/
584 __pDbStatement->BindString(2, visitedTime);
585 if(history.GetFavIconBuffer() != null)
587 __pDbStatement->BindBlob(3,*(history.GetFavIconBuffer()));
589 __pDbStatement->BindInt(4,history.GetFavIconWidth());
590 __pDbStatement->BindInt(5,history.GetFavIconHeight());
592 __pDataBase->ExecuteStatementN(*__pDbStatement);
594 if (IsFailed(GetLastResult()))
596 AppLog("PresentationModelBase::ExecuteBookmarkQuery Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
601 AppLog("PresentationModelBase::ExecuteBookmarkQuery success database");
604 else if(__isBeginTransaction == false && (queryType == L"UPDATE" || queryType == L"DELETE"))
606 r = __pDataBase->ExecuteSql(formatQuery, false);
609 AppLogException("Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
620 result PresentationModelBase::ExecuteUpdateHistoryFavIconQuery(const Tizen::Base::String& formatQuery, int& nRowCount, History& history)
622 result r = E_FAILURE;
625 r = Integer::Parse(history.GetHistoryId(), historyID);
627 if (__pDataBase == null)
629 return E_INIT_FAILED;
632 if (__pDbEnum != null)
638 if (__pDbStatement != null)
640 delete __pDbStatement;
641 __pDbStatement = null;
643 r = formatQuery.SubString(0, QUERY_TYPE_LENGTH, queryType);
645 if (__isBeginTransaction == false )
647 r = __pDataBase->BeginTransaction();
650 AppLogException("Failed Database::BeginTransaction() . (error: %s)", GetErrorMessage(r));
654 __isBeginTransaction = true;
655 __pDbStatement = __pDataBase->CreateStatementN(formatQuery);
656 if(GetLastResult() != E_SUCCESS)
658 AppLog("CreateStatementN error: %s", GetErrorMessage(GetLastResult()));
659 return GetLastResult();
661 __pDbStatement->BindBlob(0,*(history.GetFavIconBuffer()));
662 __pDbStatement->BindInt(1,history.GetFavIconWidth());
663 __pDbStatement->BindInt(2,history.GetFavIconHeight());
664 __pDbStatement->BindInt(3,historyID);
666 __pDataBase->ExecuteStatementN(*__pDbStatement);
668 if (IsFailed(GetLastResult()))
670 AppLog("PresentationModelBase::ExecuteBookmarkQuery Failed Database::ExecuteSql(). (error: %s, query: %ls)", GetErrorMessage(r), formatQuery.GetPointer());
675 AppLog("PresentationModelBase::ExecuteBookmarkQuery success database");
683 PresentationModelBase::DbIsNextRowPresent(bool& nextRowpresent)
685 result r = E_FAILURE;
687 if (null == __pDataBase || null == __pDbEnum)
689 if (__pDbEnum == null)
691 AppLogException("PresentationModelBase : pdbenum is null");
693 if (__pDataBase == null)
695 AppLogException("PresentationModelBase : __pDataBase is null");
697 return E_OUT_OF_MEMORY;
699 r = __pDbEnum->MoveNext();
702 nextRowpresent = false;
705 nextRowpresent = true;
710 PresentationModelBase::IsNullColumn(int index, bool& isColumNull)
712 if (null == __pDataBase || null == __pDbEnum)
716 isColumNull = (__pDbEnum->GetColumnType(index) == DB_COLUMNTYPE_NULL ? true : false);
722 PresentationModelBase::GetColumn(int index, String& stringValue)
724 result r = E_FAILURE;
725 DbColumnType columnType;
727 if (null == __pDataBase || null == __pDbEnum)
729 return E_OUT_OF_MEMORY;
732 columnType = __pDbEnum->GetColumnType(index);
734 //if column type is null then assign empty string and return
735 if (columnType == DB_COLUMNTYPE_NULL)
741 r = __pDbEnum->GetStringAt(index, stringValue);
744 AppLogDebug("GetStringAt: Failed");
751 PresentationModelBase::GetColumn(int index, int& intValue)
753 result r = E_FAILURE;
754 DbColumnType columnType;
756 if (null == __pDataBase || null == __pDbEnum)
758 return E_OUT_OF_MEMORY;
761 columnType = __pDbEnum->GetColumnType(index);
763 //if column type is null then assign empty string and return
764 if (columnType == DB_COLUMNTYPE_NULL)
770 r = __pDbEnum->GetIntAt(index, intValue);
771 TryCatch(!IsFailed(r),,"GetIntAt:failed %s",GetErrorMessage(r));
778 PresentationModelBase::GetColumn(int index, DateTime& dateValue)
780 result r = E_FAILURE;
783 if (null == __pDataBase || null == __pDbEnum)
785 AppLogDebug("__pDataBase or __pDbEnum is null");
786 return E_OUT_OF_MEMORY;
789 nType = __pDbEnum->GetColumnType(index);
790 //if column type is null then assign empty string and return
791 if (nType == DB_COLUMNTYPE_NULL)
796 r = __pDbEnum->GetDateTimeAt(index, dateValue);
799 AppLogDebug("GetDateTimeAt: Failed");
812 String dbColoumn = "";
813 __pDbEnum->GetStringAt(index, dbColoumn);
814 dbColoumn.IndexOf("-", 0, currIndex);
817 dbColoumn.SubString(0, currIndex ,temp);
818 Integer::Parse(temp, 10, year);
821 dbColoumn.IndexOf("-", currIndex + 1, nextIndex);
824 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex - 1 ,temp);
825 Integer::Parse(temp, 10, month);
827 currIndex = nextIndex;
829 dbColoumn.IndexOf(" ", currIndex + 1, nextIndex);
832 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex -1 ,temp);
833 Integer::Parse(temp, 10, day);
835 currIndex = nextIndex;
837 dbColoumn.IndexOf(":", currIndex + 1, nextIndex);
840 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex -1 ,temp);
841 Integer::Parse(temp, 10, hour);
843 currIndex = nextIndex;
845 dbColoumn.IndexOf(":", currIndex + 1, nextIndex);
848 dbColoumn.SubString(currIndex + 1, nextIndex - currIndex -1 ,temp);
849 Integer::Parse(temp, 10, min);
851 currIndex = nextIndex;
853 dbColoumn.SubString(currIndex + 1, temp);
854 Integer::Parse(temp, 10, sec);
856 dateValue.SetValue(year, month, day, hour, min, sec);
864 PresentationModelBase::GetColumn(int index, double& doubleValue)
866 result r = E_FAILURE;
867 DbColumnType columnType;
869 if (null == __pDataBase || null == __pDbEnum)
871 return E_OUT_OF_MEMORY;
874 columnType = __pDbEnum->GetColumnType(index);
876 //if column type is null then assign empty string and return
877 if (columnType == DB_COLUMNTYPE_NULL)
883 r = __pDbEnum->GetDoubleAt(index, doubleValue);
886 AppLogDebug("GetDateTimeAt: Failed");
894 PresentationModelBase::GetColumn(int index,Tizen::Base::ByteBuffer& favIconBuffer)
896 result r = E_FAILURE;
897 DbColumnType columnType;
899 if (null == __pDataBase || null == __pDbEnum)
901 return E_OUT_OF_MEMORY;
904 columnType = __pDbEnum->GetColumnType(index);
906 //if column type is null then assign empty string and return
907 if (columnType == DB_COLUMNTYPE_NULL)
911 favIconBuffer.Construct(__pDbEnum->GetColumnSize(index));
913 r = __pDbEnum->GetBlobAt(index, favIconBuffer);
914 AppLog("PresentationModelBase::GetColumn favicon result is %s", GetErrorMessage(r));
919 AppLogDebug("GetDateTimeAt: Failed");
927 PresentationModelBase::RollbackDb()
929 result r = E_FAILURE;
931 if (__pDataBase != null && __isBeginTransaction == true)
933 r = __pDataBase->RollbackTransaction();
938 __isBeginTransaction = false;
944 PresentationModelBase::CommitDb()
947 result r = E_FAILURE;
949 if (__pDataBase != null && __isBeginTransaction == true)
951 r = __pDataBase->CommitTransaction();
952 TryCatch(!IsFailed(r),,"PresentationModelBase::Commit Transaction:failed %s",GetErrorMessage(r));
954 __isBeginTransaction = false;
962 PresentationModelBase::GetLastInsertedId(String& tableName, int& rowId)
965 result r = E_FAILURE;
967 bool nextRowpresent = false;
969 query.Append(L"SELECT last_insert_rowid() FROM ");
970 query.Append(tableName);
972 r = PresentationModelBase::ExecuteQuery(query, count);
973 TryCatch(!IsFailed(r),,"PresentationModelBase::GetLastInsertedId query failed %s",GetErrorMessage(r));
975 r = PresentationModelBase::DbIsNextRowPresent(nextRowpresent);
977 if (nextRowpresent == true)
979 r = PresentationModelBase::GetColumn(0, rowId);
982 AppLogDebug("PresentationModelBase::GetLstInsertedId -(%s)\n", GetErrorMessage(r));
990 PresentationModelBase::GetCurrentDateTime(DateTime& dt)
993 LocaleManager localManager;
994 result r = E_FAILURE;
997 r = SystemTime::GetCurrentTime(UTC_TIME, dtNow);
1002 localManager.Construct();
1003 tz = localManager.GetSystemTimeZone();
1004 dt = tz.UtcTimeToWallTime(dtNow);
1010 PresentationModelBase::GetStringFromDate(DateTime& date)
1012 String dateFormat = L"";
1013 dateFormat.Append(date.GetYear());
1014 dateFormat.Append('-');
1015 if(date.GetMonth() < 10)
1017 dateFormat.Append('0');
1019 dateFormat.Append(date.GetMonth());
1020 dateFormat.Append('-');
1021 if(date.GetDay() < 10)
1023 dateFormat.Append('0');
1025 dateFormat.Append(date.GetDay());
1026 dateFormat.Append(' ');
1027 if(date.GetHour() < 10)
1029 dateFormat.Append('0');
1031 dateFormat.Append(date.GetHour());
1032 dateFormat.Append(':');
1033 if(date.GetMinute() < 10)
1035 dateFormat.Append('0');
1037 dateFormat.Append(date.GetMinute());
1038 dateFormat.Append(':');
1039 if(date.GetSecond() < 10)
1041 dateFormat.Append('0');
1043 dateFormat.Append(date.GetSecond());