After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 704039 - [PATCH] time zone is not respected on windows
[PATCH] time zone is not respected on windows
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Register
2.5.x
Other Windows
: Normal major
: ---
Assigned To: gnucash-ui-maint
gnucash-ui-maint
Depends on:
Blocks:
 
 
Reported: 2013-07-11 18:08 UTC by Kuang-che Wu
Modified: 2018-06-29 23:17 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kuang-che Wu 2013-07-11 18:08:01 UTC
How to reproduce:
1. Go to register and try to enter a new transaction.
2. In the date field, press "t" key in order to set it "today".
For example, now is about 2013-07-12 02:00am (GMT+8)
If I press "t", the date field become 2013-07-11.

I guess the reason of wrong date is
2013-07-12 02:00 (GMT+8) == 2013-07-11 18:00 UTC

GnuCash 2.53, windows.

IIRC, 2.4x doesn't have this problem.
Comment 1 Kuang-che Wu 2013-09-01 12:25:10 UTC
Related bug: https://bugzilla.gnome.org/show_bug.cgi?id=699422

diff --git a/src/libqof/qof/gnc-date.c b/src/libqof/qof/gnc-date.c
index 84d6388..0609c62 100644
--- a/src/libqof/qof/gnc-date.c
+++ b/src/libqof/qof/gnc-date.c
@@ -111,7 +111,7 @@ gnc_g_time_zone_new_local (void)
     gint bias = tzinfo.Bias + tzinfo.StandardBias;
     gint hours = -bias / 60; // 60 minutes per hour
     gint minutes = (bias < 0 ? -bias : bias) % 60;
-    gchar *tzstr = g_strdup_printf ("%+03d%02d", hours, minutes);
+    gchar *tzstr = g_strdup_printf ("%+02d%02d", hours, minutes);
     GTimeZone *tz = g_time_zone_new(tzstr);
     g_free (tzstr);
     return tz;
Comment 2 Kuang-che Wu 2013-09-01 12:25:36 UTC
https://bugzilla.gnome.org/show_bug.cgi?id=699977 may be relevant.
Comment 3 Christian Stimming 2013-09-01 21:08:02 UTC
Patch/diff looks good to me and should be committed.

Unfortunately the gnucash servers seem to be down right now, but once they're up again, this should go in.
Comment 4 Geert Janssens 2013-09-03 13:37:38 UTC
I have committed your patch as r23155 on the trunk branch. Thank you very much!

For the related bugs, I will ask the respective posters to verify if your patch fixes their bugs as well. I assume it will. After confirmation, these bugs can be closed as duplicates of this one.
Comment 5 Kuang-che Wu 2013-09-04 16:43:51 UTC
I verified this bug using nightly build.
http://code.gnucash.org/builds/win32/trunk/gnucash-2.5.4-2013-09-04-git-6ee4202+-setup.exe
Comment 6 Geert Janssens 2013-09-04 16:52:03 UTC
Thank you.
Comment 7 Kuang-che Wu 2013-09-09 18:15:25 UTC
just found another

diff --git a/src/libqof/qof/gnc-date.c b/src/libqof/qof/gnc-date.c
index 0609c62..ecc951c 100644
--- a/src/libqof/qof/gnc-date.c
+++ b/src/libqof/qof/gnc-date.c
@@ -142,7 +142,7 @@ gnc_g_time_zone_adjust_for_dst (GTimeZone* tz, GDateTime *date)
        bias = tzinfo.Bias + tzinfo.DaylightBias;
        hours = -bias / 60; // 60 minutes per hour
        minutes = (bias < 0 ? -bias : bias) % 60;
-       tzstr = g_strdup_printf ("%+03d%02d", hours, minutes);
+       tzstr = g_strdup_printf ("%+02d%02d", hours, minutes);
        tz = g_time_zone_new(tzstr);
     }
 #endif
Comment 8 David Carlson 2013-09-11 02:50:49 UTC
Running 2.5.5 in a Windows 7 64 bit machine set to Central Daylight Time (UTC -6:00) at 9:45 pm, pressing 'T' in the date posted field of a register2 account view sets the date to tomorrow's date.

Pressing shift+ or shift- on a numeric keyboard shifts the date 7 days, Alt+ or Alt- on a numeric keyboard shifts month by one and Ctrl+ or Ctrl- on a numeric keyboard shifts year by one.
Comment 9 John Ralls 2013-09-19 19:24:09 UTC
(In reply to comment #7)
> just found another
> 
> diff --git a/src/libqof/qof/gnc-date.c b/src/libqof/qof/gnc-date.c
> index 0609c62..ecc951c 100644
> --- a/src/libqof/qof/gnc-date.c
> +++ b/src/libqof/qof/gnc-date.c
> @@ -142,7 +142,7 @@ gnc_g_time_zone_adjust_for_dst (GTimeZone* tz, GDateTime
> *date)
>         bias = tzinfo.Bias + tzinfo.DaylightBias;
>         hours = -bias / 60; // 60 minutes per hour
>         minutes = (bias < 0 ? -bias : bias) % 60;
> -       tzstr = g_strdup_printf ("%+03d%02d", hours, minutes);
> +       tzstr = g_strdup_printf ("%+02d%02d", hours, minutes);
>         tz = g_time_zone_new(tzstr);
>      }
>  #endif

Committed as r23179, thanks.
Comment 10 John Ralls 2013-09-19 19:25:15 UTC
(In reply to comment #8)
> Running 2.5.5 in a Windows 7 64 bit machine set to Central Daylight Time (UTC
> -6:00) at 9:45 pm, pressing 'T' in the date posted field of a register2 account
> view sets the date to tomorrow's date.

Please try again with tomorrow's nightly.

> Pressing shift+ or shift- on a numeric keyboard shifts the date 7 days, Alt+ or
> Alt- on a numeric keyboard shifts month by one and Ctrl+ or Ctrl- on a numeric
> keyboard shifts year by one.

Sounds like a feature. What's the problem?
Comment 11 David Carlson 2013-09-19 22:10:19 UTC
Actually, yes, the other features, like the 'T(oday)' feature, are nice. I found them in an old bug report, and because they work, I really want them to be documented in the user manual.  

I listed them here because I did not want to forget about them.  To date I have not researched where to put them in the documentation.  Also, I do not know if they work when there is no separate numeric keypad.  I think that should also be mentioned in the documentation.

Alas, I have not developed the ability to use nightly builds.  I will wait for the 2.5.6 release.
Comment 12 John Ralls 2013-09-19 22:18:21 UTC
> Alas, I have not developed the ability to use nightly builds.  I will wait for
> the 2.5.6 release.

Download from here:
http://code.gnucash.org/builds/win32/trunk/
But I see that they're borked again, so it will probably be a day or two.
Comment 13 Kuang-che Wu 2013-09-20 13:48:35 UTC
Fixed. Verified using nightly build.
Comment 14 John Ralls 2018-06-29 23:17:19 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=704039. Please update any external references or bookmarks.