John,

Still no luck with your revised patch. There is no codecvt header file but
I did find one in bits/codecvt.h, tried adding that instead but still
failed, looked in that file and seemed to imply it should not be used
directly and maybe locale is the way to go.
Tried that and get the following error...

c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp: In member function
'void TimeZoneProvider::load_windows_default_tz
()':
c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:241:5: error:
'wstring_convert' is not a member of 'std'
     std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t>
conversion;
     ^
c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:241:26: error:
'codecvt_utf8_utf16' is not a member of 'std'
     std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t>
conversion;
                          ^
c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:241:50: error:
expected primary-expression before 'char16_t'
     std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t>
conversion;
                                                  ^
c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:241:50: error:
expected ';' before 'char16_t'
c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:242:21: error:
'conversion' was not declared in this scope
     auto std_name = conversion.to_bytes(tzi.StandardName);
                     ^
At global scope:
cc1plus.exe: error: unrecognized command line option
"-Wno-deprecated-register" [-Werror]
cc1plus.exe: all warnings being treated as errors

Attached are the changes I am currently using.

Regards,

     Robert


On 24 July 2015 at 18:13, John Ralls <jra...@ceridwen.us> wrote:

>
> > On Jul 24, 2015, at 6:09 AM, Robert Fewell <14ubo...@gmail.com> wrote:
> >
> > John,
> >
> > Still trying to compile with your patch with the following changes for
> load_windows_default_tz...
> >
> > void
> > TimeZoneProvider::load_windows_default_tz()
> > {
> >     TIME_ZONE_INFORMATION tzi {};
> >     if (GetTimeZoneInformation (&tzi) == TIME_ZONE_ID_INVALID)
> >         throw std::invalid_argument ("No default time zone.");
> >     RegTZI regtzi { tzi.Bias, tzi.StandardBias, tzi.DaylightBias,
> tzi.StandardDate, tzi.DaylightDate };
> >
> >     time_zone_names names (tzi.StandardName, tzi.StandardName,
> tzi.DaylightName, tzi.DaylightName);
> >
> >     zone_vector.push_back(std::make_pair(0, zone_from_regtzi(regtzi,
> names)));
> > }
> >
> > and I also added this to hpp file line 63...
> >
> >     void load_windows_default_tz(void);
> >
> > but am getting this error...
> >
> > c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp: In member function
> 'void TimeZoneProvider::load_windows_default_tz
> > ()':
> > c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:237:98: error: no
> matching function for call to 'boost::date_time::
> > time_zone_names_base<char>::time_zone_names_base(WCHAR [32], WCHAR [32],
> WCHAR [32], WCHAR [32])'
> >      time_zone_names names (tzi.StandardName, tzi.StandardName,
> tzi.DaylightName, tzi.DaylightName);
> >
>
>    ^
> > c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:237:98: note:
> candidates are:
> > In file included from
> c:/gcdev/boost/include/boost/date_time/local_time/custom_time_zone.hpp:12:0,
> >                  from
> c:/gcdev/boost/include/boost/date_time/local_time/local_time_types.hpp:18,
> >                  from
> c:/gcdev/boost/include/boost/date_time/local_time/local_time.hpp:13,
> >                  from
> c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.hpp:34,
> >                  from
> c:/gcdev/gnucash.git/src/libqof/qof/gnc-timezone.cpp:23:
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:59:5: note:
> boost::date_time::time_zone_names_base<CharT>::ti
> > me_zone_names_base(const string_type&, const string_type&, const
> string_type&, const string_type&) [with CharT = char; b
> > oost::date_time::time_zone_names_base<CharT>::string_type =
> std::basic_string<char>]
> >      time_zone_names_base(const string_type& std_zone_name_str,
> >      ^
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:59:5: note:
>  no known conversion for argument 1 from 'WCHAR
> > [32] {aka wchar_t [32]}' to 'const string_type& {aka const
> std::basic_string<char>&}'
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:53:5: note:
> boost::date_time::time_zone_names_base<CharT>::ti
> > me_zone_names_base() [with CharT = char]
> >      time_zone_names_base() :
> >      ^
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:53:5: note:
>  candidate expects 0 arguments, 4 provided
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:49:9: note:
> boost::date_time::time_zone_names_base<char>::tim
> > e_zone_names_base(const boost::date_time::time_zone_names_base<char>&)
> >    class time_zone_names_base
> >             ^
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:49:9: note:
>  candidate expects 1 argument, 4 provided
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:49:9: note:
> boost::date_time::time_zone_names_base<char>::tim
> > e_zone_names_base(boost::date_time::time_zone_names_base<char>&&)
> > c:/gcdev/boost/include/boost/date_time/time_zone_names.hpp:49:9: note:
>  candidate expects 1 argument, 4 provided
> > At global scope:
> > cc1plus.exe: error: unrecognized command line option
> "-Wno-deprecated-register" [-Werror]
> > cc1plus.exe: all warnings being treated as errors
> >
> > Will ponder further but you may beat me to an answer.
> >
>
> Robert,
>
> Ah, right, tzi.StandardName and tzi.DaylightName are wchar_t[] and boost
> doesn’t know what to do with them. This revised patch might work.
>
> Regards,
> John Ralls
>
>
>
>
From 91dae5cc62df5092a497a1dbd78dfcd69f6bfa0f Mon Sep 17 00:00:00 2001
From: Robert Fewell <14ubo...@gmail.com>
Date: Sat, 25 Jul 2015 10:15:58 +0100
Subject: [PATCH] Windows: Get default timezone if there's no default key.

Windows XP doesn't provide a default key, just the TZI returned by
GetDefaultTimeZone(), so use that instead of throwing if there's no
default key in the registry. If GetDefaultTimeZone() files, throw: We
can't safely read the database without a timezone.
---
 src/libqof/qof/gnc-timezone.cpp | 24 ++++++++++++++++++++++--
 src/libqof/qof/gnc-timezone.hpp |  1 +
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/libqof/qof/gnc-timezone.cpp b/src/libqof/qof/gnc-timezone.cpp
index a6804eb..0f53ed1 100644
--- a/src/libqof/qof/gnc-timezone.cpp
+++ b/src/libqof/qof/gnc-timezone.cpp
@@ -27,6 +27,10 @@
 #include <istream>
 #include <algorithm>
 #include <boost/date_time/gregorian/gregorian.hpp>
+#if PLATFORM(WINDOWS)
+#include <locale>
+#endif
+
 using namespace gnc::date;
 
 using duration = boost::posix_time::time_duration;
@@ -226,6 +229,21 @@ TimeZoneProvider::load_windows_classic_tz (HKEY key, time_zone_names names)
     RegCloseKey (key);
 }
 
+void
+TimeZoneProvider::load_windows_default_tz()
+{
+    TIME_ZONE_INFORMATION tzi {};
+    if (GetTimeZoneInformation (&tzi) == TIME_ZONE_ID_INVALID)
+        throw std::invalid_argument ("No default time zone.");
+    RegTZI regtzi { tzi.Bias, tzi.StandardBias, tzi.DaylightBias,
+            tzi.StandardDate, tzi.DaylightDate };
+    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> conversion;
+    auto std_name = conversion.to_bytes(tzi.StandardName);
+    auto dlt_name = conversion.to_bytes(tzi.DaylightName);
+    time_zone_names names (std_name, std_name, dlt_name, dlt_name);
+    zone_vector.push_back(std::make_pair(0, zone_from_regtzi(regtzi, names)));
+}
+
 TimeZoneProvider::TimeZoneProvider (const std::string& identifier) :
     zone_vector ()
 {
@@ -237,8 +255,10 @@ TimeZoneProvider::TimeZoneProvider (const std::string& identifier) :
 		     identifier);
 
     if (key_name.empty())
-	throw std::invalid_argument ("No identifier or default tzname.");
-
+    {
+        load_windows_default_tz();
+        return;
+    }
     std::string subkey = reg_key + key_name;
     if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, subkey.c_str(), 0,
 		       KEY_QUERY_VALUE, &key) != ERROR_SUCCESS)
diff --git a/src/libqof/qof/gnc-timezone.hpp b/src/libqof/qof/gnc-timezone.hpp
index 9988b87..a7affdf 100644
--- a/src/libqof/qof/gnc-timezone.hpp
+++ b/src/libqof/qof/gnc-timezone.hpp
@@ -60,6 +60,7 @@ private:
 #if PLATFORM(WINDOWS)
     void load_windows_dynamic_tz(HKEY, time_zone_names);
     void load_windows_classic_tz(HKEY, time_zone_names);
+    void load_windows_default_tz(void);
 #endif
 };
 
-- 
2.3.6

_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to