OSDN Git Service

First pass at relative times in log. This version shows both local and relative time...
[tortoisegit/TortoiseGitJp.git] / src / Git / GitRev.cpp
index 9ae6b61..9f06c61 100644 (file)
@@ -172,13 +172,48 @@ int GitRev::ParserFromLog(BYTE_VECTOR &log,int start)
 \r
 CTime GitRev::ConverFromString(CString input)\r
 {\r
+       // pick up date from string\r
        CTime tm(_wtoi(input.Mid(0,4)),\r
                         _wtoi(input.Mid(5,2)),\r
                         _wtoi(input.Mid(8,2)),\r
                         _wtoi(input.Mid(11,2)),\r
                         _wtoi(input.Mid(14,2)),\r
                         _wtoi(input.Mid(17,2)),\r
-                        _wtoi(input.Mid(20,4)));\r
+                        0);\r
+       // pick up utc offset\r
+       CString sign = input.Mid(20,1);         // + or -\r
+       int hoursOffset =  _wtoi(input.Mid(21,2));\r
+       int minsOffset = _wtoi(input.Mid(23,2));\r
+       if ( sign == "-" )\r
+       {\r
+               hoursOffset = -hoursOffset;\r
+               minsOffset = -minsOffset;\r
+       }\r
+       // make a timespan object with this value\r
+       CTimeSpan offset( 0, hoursOffset, minsOffset, 0 );\r
+       // we have to subtract this from the time given to get UTC\r
+       tm -= offset;\r
+       // get local timezone\r
+       SYSTEMTIME sysTime;\r
+       tm.GetAsSystemTime( sysTime );\r
+       TIME_ZONE_INFORMATION timeZone;\r
+       if ( GetTimeZoneInformation( &timeZone ) == TIME_ZONE_ID_UNKNOWN )\r
+       {\r
+               ASSERT(false);\r
+       }\r
+       else\r
+       {\r
+               SYSTEMTIME local;\r
+               if ( SystemTimeToTzSpecificLocalTime( &timeZone, &sysTime, &local ) )\r
+               {\r
+                       sysTime = local;\r
+               }\r
+               else\r
+               {\r
+                       ASSERT(false);\r
+               }\r
+       }\r
+       tm = CTime( sysTime, 0 );\r
        return tm;\r
 }\r
 \r