Bug 378481 - Entering **/**/17 in a date field saves as the year 1917
Summary: Entering **/**/17 in a date field saves as the year 1917
Status: CLOSED FIXED
Alias: None
Product: KEXI
Classification: Applications
Component: Tables (show other bugs)
Version: 3.1.0 Alpha
Platform: Other All
: HI normal
Target Milestone: 3.2
Assignee: Jarosław Staniek
URL: https://phabricator.kde.org/D18035
Keywords:
Depends on: 369518
Blocks:
  Show dependency treegraph
 
Reported: 2017-04-05 23:02 UTC by Jarosław Staniek
Modified: 2023-09-03 20:46 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 3.2.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jarosław Staniek 2017-04-05 23:02:36 UTC
Entering **/**/17 in a date field saves as the year 1917.

Verify in tables and forms.
Comment 1 Jarosław Staniek 2017-04-05 23:03:04 UTC
(report by clickoclunko@gmail.com)
Comment 2 Jarosław Staniek 2017-04-06 10:22:57 UTC
Forum topic: https://forum.kde.org/viewtopic.php?f=221&t=139802
Comment 3 Jarosław Staniek 2017-11-30 16:28:47 UTC
Initial remarks:
- the real problem is lack of precision regarding years number if the current short date format is set to two digits (which is the case if the locale is "C" or en_US); thus the *input* format does not allow precise input
- assuming the user input is correct the date is always stored correctly (in locale-independent precise ISO 8601 format)

(Development note) Future Kexi can work around this problem in many ways:
- by automatically default to 4 digit year in any formats (seems to me similar to newer Access https://support.office.com/en-us/article/Format-the-date-and-time-field-in-Access-47fbbdc1-52fa-416a-b8d5-ba24d881b698#__toc260216068)
- by allowing to change the format in the application to override the system settings
- by allowing to change the same in given Kexi project
- by allowing to change the same in given object (table, form, report, query...)
- support legacy approach known e.g. from MS Access (explained in the warning https://support.office.com/en-us/article/Format-Property-Date-Time-Data-Type-3251a423-3dd7-446e-be65-c7293eddbb43) - it's generally safe, unless dates before 1930 are used, for example Ian is using them so he would need 4 digits years instead - https://forum.kde.org/viewtopic.php?f=221&t=139802)

Current solution explained below is *proper* too and works for Kexi 3.1 Alpha, 3.0 and older. It's not a workaround as the problem exists for any application that uses the system's (or user's) global settings for the date format.

SOLUTION without fixing Kexi: change your locale for date/time to use four years digits. For example dd-mm-yyyy format could be achieved by using English-Denmark date/time.

How? Two ways:

Approach 1. On Linux use the LC_TIME environment variable prior to running Kexi

LC_TIME=en_DK kexi
(or "LC_TIME=en_DK kexi-3.1" for Kexi 3.1)
("LC_TIME=en_DK /path/to/kexi-******x86_64.AppImage" works too for app images)

This approach affects only Kexi. You can create a script, alias or desktop shortcut to make this choice persistent.

Approach 2. Change the date/time locale in your desktop environment of choice (find instructions how to do that, often it can be done graphically). This is persistent change for all applications behaving like Kexi and can affect both default settings for input and display (e.g. in printouts).

If you prefer dd/mm/yyyy use locale LC_TIME=en_GB instead.
Comment 4 Jarosław Staniek 2018-12-31 13:19:36 UTC
More backgroun on the problem, it's not in KF, Qt or KEXI but in Unicode.org. 
https://marc.info/?t=154384500600001&r=1&w=2

The LC_TIME=en_DK workaround for KEXI is still valid.

I plan to add a workarroubnd that forcibly replaces two-digit years in any formats to four-digits. Possible option for reverting that is possible in the future for people that know that two digits work for them (e.g. because they smaller date ranges)
Comment 5 Jarosław Staniek 2019-01-03 23:31:52 UTC
Fix in progress. Sample info KEXI shows on output when LC_TIME=en_US is used:

Two-digit year formats for dates are not allowed so KEXI will alter date format "M/d/yy" by replacing two-digits years with four-digits for accuracy. New input format is "M/d/yyyy", new input mask is "90/90/9999" and new output format is "M/d/yyyy". This change will affect input and display. Set the General/AllowTwoDigitYearFormats option to true to enable use of two-digit year formats.
Comment 6 Jarosław Staniek 2019-01-07 09:35:20 UTC
Test db: use from https://bugs.kde.org/show_bug.cgi?id=369518
Comment 7 Jarosław Staniek 2019-01-07 09:59:26 UTC
Git commit 0928be1075aa424f9c208844de6f9c54329b4375 by Jaroslaw Staniek.
Committed on 07/01/2019 at 09:57.
Pushed by staniek into branch '378481-date-entry'.

Fix two-digit year formats issue: not allow by default

Summary: BUG:378481

Test Plan:
1. Run "LC_TIME=en_US kexi-3.2", open test db from https://bugs.kde.org/show_bug.cgi?id=369518

Expected:
Years are 4 digits now in tables and forms. On the output INFO message says as explained at https://bugs.kde.org/show_bug.cgi?id=378481#c5.
Data entry works based on this new year format. Changes are properly saved to db.
Display output e.g. in queries and reports follow this format too.

2. Set kexirc to
[General]
AllowTwoDigitYearFormats=true

And restart KEXI and open the same db.

Expected: original behavior: two-digit years.

Reviewers: piggz

Subscribers: Kexi-Devel-list

Tags: #kexi

Differential Revision: https://phabricator.kde.org/D18035

M  +8    -0    src/doc/dev/settings.txt
M  +51   -7    src/widget/utils/kexidatetimeformatter.cpp

https://commits.kde.org/kexi/0928be1075aa424f9c208844de6f9c54329b4375
Comment 8 Jarosław Staniek 2019-01-11 16:37:06 UTC
Git commit b37727d3f688d3db1f6a858836831eb16ac05485 by Jaroslaw Staniek.
Committed on 11/01/2019 at 16:34.
Pushed by staniek into branch '3.2'.

Fix two-digit year formats issue: not allow by default
FIXED-IN:3.2.0

Summary:

Test Plan:
1. Run "LC_TIME=en_US kexi-3.2", open test db from https://bugs.kde.org/show_bug.cgi?id=369518

Expected:
Years are 4 digits now in tables and forms. On the output INFO message says as explained at https://bugs.kde.org/show_bug.cgi?id=378481#c5.
Data entry works based on this new year format. Changes are properly saved to db.
Display output e.g. in queries and reports follow this format too.

2. Set kexirc to
[General]
AllowTwoDigitYearFormats=true

And restart KEXI and open the same db.

Expected: original behavior: two-digit years.

Reviewers: piggz

Subscribers: Kexi-Devel-list

Tags: #kexi

Differential Revision: https://phabricator.kde.org/D18035

M  +8    -0    src/doc/dev/settings.txt
M  +51   -7    src/widget/utils/kexidatetimeformatter.cpp

https://commits.kde.org/kexi/b37727d3f688d3db1f6a858836831eb16ac05485