Project

General

Profile

Bug #9855

Date FILL-IN: adjusts DATE format to SESSION:DATE-FORMAT order

Added by Vladimir Tsichevski over 1 year ago. Updated about 1 year ago.

Status:
Test
Priority:
Normal
Assignee:
Vladimir Tsichevski
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
15823
version_resolved:
reviewer:
production:
No
env_name:
topics:

TestDateFormatTransition.cls (5.55 KB) Vladimir Tsichevski, 03/29/2025 06:41 AM

TestDateFormatAdjustment.cls (11.3 KB) Vladimir Tsichevski, 03/30/2025 06:50 PM

TestDateFormatAdjustmentDeclaration.cls (19.3 KB) Vladimir Tsichevski, 03/31/2025 05:23 PM

DateFormatAdjustmentDisplay.cls (10.7 KB) Vladimir Tsichevski, 03/31/2025 05:25 PM

DisplayDateFormatDeclarationAdjustmentAll.cls (70 KB) Vladimir Tsichevski, 04/02/2025 08:38 AM

display-date-format-assignment-adjustment.p Magnifier (2.38 KB) Vladimir Tsichevski, 04/02/2025 08:40 AM

DateFormatAdjuster.java Magnifier (6.72 KB) Vladimir Tsichevski, 04/02/2025 09:54 AM

test-date-format-formatting-adjustment.p Magnifier (3.19 KB) Vladimir Tsichevski, 04/02/2025 02:39 PM

TestDateFormatAdjustment.cls (2.79 KB) Vladimir Tsichevski, 04/03/2025 03:12 PM

date_format_assignment_adjusted_dmy.i (8.16 KB) Vladimir Tsichevski, 04/03/2025 03:13 PM

date_format_assignment_adjusted_dym.i (8.16 KB) Vladimir Tsichevski, 04/03/2025 03:13 PM

date_format_assignment_adjusted_mdy.i (8.16 KB) Vladimir Tsichevski, 04/03/2025 03:13 PM

date_format_assignment_adjusted_myd.i (8.16 KB) Vladimir Tsichevski, 04/03/2025 03:13 PM

date_format_assignment_adjusted_ydm.i (8.16 KB) Vladimir Tsichevski, 04/03/2025 03:13 PM

date_format_assignment_adjusted_ymd.i (8.16 KB) Vladimir Tsichevski, 04/03/2025 03:13 PM


Related issues

Related to User Interface - Bug #7515: FILL-IN: editing dates issues WIP
Related to User Interface - Bug #10197: Datetime, datetime-tz FILL-IN: adjusts DATETIME format to SESSION:DATE-FORMAT order New

History

#1 Updated by Vladimir Tsichevski over 1 year ago

When a DATE variable’s FORMAT is set (e.g., d:FORMAT = "99/99.9999"), FWD should modify the format to match SESSION:DATE-FORMAT.

Demo Example Program

The following program demonstrates the issue by testing various FORMAT settings across all valid SESSION:DATE-FORMAT values and comparing the set versus applied formats:

DEFAULT-WINDOW:WIDTH-CHARS = 65.
DEFAULT-WINDOW:HEIGHT-CHARS = 15.

DEFINE VARIABLE d AS DATE NO-UNDO.

DEFINE FRAME myFrame
   d
   WITH NO-LABELS NO-BOX DOWN SIZE 62 BY 10.

DEFINE VARIABLE dateFormats AS CHARACTER NO-UNDO EXTENT 6
   INITIAL ["mdy", "dmy", "ymd", "myd", "dym", "ydm"].

DEFINE VARIABLE varFormats AS CHARACTER NO-UNDO EXTENT 3
   INITIAL ["99/99.9999", "9999-99.99", "9999-9999.9999"].

DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.

OUTPUT TO "date_format_test.txt".

REPEAT i = 1 TO EXTENT(dateFormats):
    SESSION:DATE-FORMAT = dateFormats[i].
    DISPLAY "SESSION:DATE-FORMAT = " + SESSION:DATE-FORMAT FORMAT "x(30)".
    REPEAT j = 1 TO EXTENT(varFormats):
        d:FORMAT IN FRAME myFrame = varFormats[j].
        DISPLAY "  Format Set = " + varFormats[j] FORMAT "x(30)" 
                "Applied Format = " + d:FORMAT IN FRAME myFrame FORMAT "x(35)".
    END.
END.

OUTPUT CLOSE.

FWD Program Output

FWD does not adjust d:FORMAT, so the "Applied Format" matches the "Format Set" exactly, regardless of SESSION:DATE-FORMAT:

SESSION:DATE-FORMAT = mdy

  Format Set = 99/99.9999        Applied Format = 99/99.9999
  Format Set = 9999-99.99        Applied Format = 99-99.9999
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = dmy

  Format Set = 99/99.9999        Applied Format = 99/99.9999
  Format Set = 9999-99.99        Applied Format = 99.99-9999
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = ymd

  Format Set = 99/99.9999        Applied Format = 9999.99/99
  Format Set = 9999-99.99        Applied Format = 9999-99.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = myd

  Format Set = 99/99.9999        Applied Format = 99/9999.99
  Format Set = 9999-99.99        Applied Format = 99-9999.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = dym

  Format Set = 99/99.9999        Applied Format = 99.9999.99
  Format Set = 9999-99.99        Applied Format = 99.9999.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = ydm

  Format Set = 99/99.9999        Applied Format = 9999.99.99
  Format Set = 9999-99.99        Applied Format = 9999-99.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

Expected Program Output

In OE FORMAT is adjusted to match SESSION:DATE-FORMAT, reordering date components and repositioning separators:

SESSION:DATE-FORMAT = mdy

  Format Set = 99/99.9999        Applied Format = 99/99.9999
  Format Set = 9999-99.99        Applied Format = 99-99.9999
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = dmy

  Format Set = 99/99.9999        Applied Format = 99/99.9999
  Format Set = 9999-99.99        Applied Format = 99.99-9999
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = ymd

  Format Set = 99/99.9999        Applied Format = 9999.99/99
  Format Set = 9999-99.99        Applied Format = 9999-99.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = myd

  Format Set = 99/99.9999        Applied Format = 99/9999.99
  Format Set = 9999-99.99        Applied Format = 99-9999.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = dym

  Format Set = 99/99.9999        Applied Format = 99.9999.99
  Format Set = 9999-99.99        Applied Format = 99.9999.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

SESSION:DATE-FORMAT = ydm

  Format Set = 99/99.9999        Applied Format = 9999.99.99
  Format Set = 9999-99.99        Applied Format = 9999-99.99
  Format Set = 9999-9999.9999    Applied Format = 9999-9999.9999

#2 Updated by Vladimir Tsichevski over 1 year ago

The attached TestDateFormatTransition.cls contains ABLUnit tests.

#3 Updated by Vladimir Tsichevski over 1 year ago

Attached TestDateFormatAdjustment.cls is an advanced unit test class, which tests all (72) possible date format permutations.

#4 Updated by Vladimir Tsichevski over 1 year ago

Here are the rules for date format adjustments in OE. It determine:

  1. In which situations format adjustment is required.
  2. How separators are adjusted when a format change occurs.

In Which Situations Format Adjustment is Required

Format adjustment is required under the following conditions:

  1. The new format includes separators (i.e., it is not a no-separator format like 999999 or 99999999).
  2. The new requested format’s component order or lengths do not match the current SESSION:DATE-FORMAT order, such as:
    1. A short component specification (99) for the year component, and
    2. A long component specification (9999) for exactly one other component (month or day).

Note: Adjustment depends only on the new format being set and the current SESSION:DATE-FORMAT value. Changing SESSION:DATE-FORMAT does not affect existing formats.

Separators Adjustment Rules

When a new format is applied, separators are modified based on the SESSION:DATE-FORMAT:

  1. Month in first position (mdy, myd): Preserves separators; the original separators in the new format remain unchanged (e.g., - and . stay - and .).
  1. Month in middle position (dmy, ymd): Separators swap positions (e.g., - and . become . and -).
  1. Month in last position (dym, ydm): The second separator is copied to the first position, replacing the original first separator (e.g., - and . become . and .; . and - become - and -).

#5 Updated by Vladimir Tsichevski over 1 year ago

Format adjustment can occur also in a date variable declaration, but the adjustment rules differs.

I've created a class to capture the format adjustment for all format permutations (DateFormatAdjustmentDisplay.cls), and, based on the output of this program, the "real" unit test class TestDateFormatAdjustmentDeclaration.cls.

The output analyses proves that:

  1. The rules for date components adjustments for date variable declaration is the same as the rules for date format assignment.
  2. The rules for separators adjustments differs:

When a DATE variable is declared with a FORMAT clause, OpenEdge adjusts the separators based on SESSION:DATE-FORMAT as follows:

mdy, dmy, dym (Preserved)

The declared separators remain unchanged.

Examples:

- mdy: 9999.99/9999.99/9999, 9999-99.9999-99.9999
- dmy: 99/9999-9999/99-9999
- dym: 9999-99.9999-9999.99

ymd, myd (Swap)

The first and second separators are exchanged.

Examples:

- ymd: 99.9999/999999/99.99, 99-99.99999999.99-99
- myd: 9999.99/9999/9999.99, 99/99-999999-9999/99

ydm (Copy 2 to 1)

The second separator overwrites the first; the second remains unchanged.

Examples:

- ydm: 99.9999/999999/99/99, 99-99.999999.9999.99

#6 Updated by Vladimir Tsichevski over 1 year ago

  • % Done changed from 40 to 50

UPD1: Formats are also adjusted when converting a date to a string, such as with STRING(d, "99/99/9999").
UPD2: A format component may consist of any number of nines from 1 to 4, not just 99 or 9999.

Both scenarios require further investigation.

#7 Updated by Vladimir Tsichevski over 1 year ago

Vladimir Tsichevski wrote:

UPD2: A format component may consist of any number of nines from 1 to 4, not just 99 or 9999.

I've created two test programs which capture format adjusting both for date variable declaration and date format attribute assignment for all 576 possible date formats.

I’ve created two data collection programs in OpenEdge ABL.

The first program DisplayDateFormatDeclarationAdjustmentAll.cls collects data on format adjustments for variable declarations, while the second display-date-format-assignment-adjustment.p collects data on format adjustments for format assignments.

The experiment revealed that the data obtained for variable declarations and format assignments are identical.
Converting the data to a string might yield similar results, though this hypothesis requires testing.

#8 Updated by Vladimir Tsichevski over 1 year ago

Attached is a class DateFormatAdjuster.java with the reorderForDateFormatAssignment method, which does format adjustment compatible with both OE date format declaration and date attribute assignment adjustment.

#9 Updated by Vladimir Tsichevski over 1 year ago

Attached is a test-date-format-formatting-adjustment.p 4gl procedure, which proves the hypothesis that format adjustments applied during date formatting are identical to those applied in date format declarations and date format assignments in OE for each possible SESSION:DATE-FORMAT setting.

#10 Updated by Vladimir Tsichevski over 1 year ago

Update: Aside from one exception, date format components can consist of any positive number of nines, resulting in an unlimited number of possible formats. Fortunately, this does not appear to affect the adjustment rules. The critical component length for adjustments remains four nines, consistent with existing behavior. The exception, where the leftmost component may be an empty string (e.g., ".99.9999"), is most probably an implementation bug in OE and we will not consider valid in our context.

#11 Updated by Vladimir Tsichevski over 1 year ago

Date format adjustment implemented in 9855a rev. 15830. The result passes TestDateFormatAdjustment.cls tests.

#12 Updated by Vladimir Tsichevski over 1 year ago

  • % Done changed from 70 to 90
  • Status changed from WIP to Review
  • reviewer Hynek Cihlar added

Hynek, please, review.

The remaining things:

  1. I didn’t sort fields and methods in the modified classes to keep the changes easier to review.
  2. Conduct a similar investigation for datetime formats, as I suspect they will require changes analogous to those made for date formats.

#13 Updated by Vladimir Tsichevski over 1 year ago

I found that date.getDateOrderNative() returns date order strings like "mdy", so I can now eliminate the Order enum I added to convert the 3-byte array into a string representation.

The change is in 9855a rev. 15831.

#14 Updated by Vladimir Tsichevski over 1 year ago

In revision 15832, a regression was resolved in the ParsedDateFormat.toString() method, which had incorrectly inserted zero-code characters into no-separator formats (e.g., "999999") where separators were absent, rather than leaving them out.

#15 Updated by Vladimir Tsichevski over 1 year ago

  • Related to Bug #7515: FILL-IN: editing dates issues added

#16 Updated by Hynek Cihlar about 1 year ago

Code review 9855a.

The changes look good. Please also regression test ChUI beside GUI.

Anything left? Should the issue be marked as 100%?

#17 Updated by Hynek Cihlar about 1 year ago

+Hynek

#18 Updated by Vladimir Tsichevski about 1 year ago

Hynek Cihlar wrote:

Code review 9855a.

The changes look good. Please also regression test ChUI beside GUI.

I need to ask somebody to run ChUI regression test on my behalf, since this does not work on my workstation.

Anything left? Should the issue be marked as 100%?

As I mentioned in #9855-12:

  1. Sort class body members in the modified classes.
  2. Conduct a similar investigation for datetime and datetime-tz formats. I will create a new task for this work.

#19 Updated by Hynek Cihlar about 1 year ago

Vladimir Tsichevski wrote:

I need to ask somebody to run ChUI regression test on my behalf, since this does not work on my workstation.

I'll run it.

#20 Updated by Vladimir Tsichevski about 1 year ago

Vladimir Tsichevski wrote:

Hynek Cihlar wrote:

Code review 9855a.

The changes look good. Please also regression test ChUI beside GUI.

I need to ask somebody to run ChUI regression test on my behalf, since this does not work on my workstation.

Anything left? Should the issue be marked as 100%?

As I mentioned in #9855-12:

  1. Sort class body members in the modified classes.

Done in 9855a rev. 16000.

#21 Updated by Vladimir Tsichevski about 1 year ago

  • Related to Bug #10197: Datetime, datetime-tz FILL-IN: adjusts DATETIME format to SESSION:DATE-FORMAT order added

#22 Updated by Vladimir Tsichevski about 1 year ago

Vladimir Tsichevski wrote:

  1. Conduct a similar investigation for datetime and datetime-tz formats. I will create a new task for this work.

Created the #10197 for this work.

#23 Updated by Vladimir Tsichevski about 1 year ago

  • % Done changed from 90 to 100

#24 Updated by Hynek Cihlar about 1 year ago

Vladimir Tsichevski wrote:

Done in 9855a rev. 16000.

The line final byte[] orderBytes = date.getDateComponentOrder(); was removed in the commit, was this expected? Otherwise the changes look OK.

#25 Updated by Vladimir Tsichevski about 1 year ago

Hynek Cihlar wrote:

Vladimir Tsichevski wrote:

Done in 9855a rev. 16000.

The line final byte[] orderBytes = date.getDateComponentOrder(); was removed in the commit, was this expected? Otherwise the changes look OK.

Yes, this variable is not used anymore.

#26 Updated by Hynek Cihlar about 1 year ago

9855a passed ChUI regression tests.

#27 Updated by Vladimir Tsichevski about 1 year ago

Hynek Cihlar wrote:

9855a passed ChUI regression tests.

I think, this change can be merged then.

#28 Updated by Hynek Cihlar about 1 year ago

  • Status changed from Review to Merge Pending

Please go ahead and merge 9855a.

#29 Updated by Vladimir Tsichevski about 1 year ago

Hynek Cihlar wrote:

Please go ahead and merge 9855a.

Merged as trunk rev. 16001.

#30 Updated by Greg Shah about 1 year ago

  • Status changed from Merge Pending to Test

Also available in: Atom PDF