Project

General

Profile

Bug #10538

QUOTER strips time part in datetime and datetime-tz

Added by Eduard Soltan 11 months ago. Updated 10 months ago.

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

100%

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

History

#1 Updated by Eduard Soltan 11 months ago

Found a different behaviour between 4GL and FWD in the following test case:

def var date1 as datetime-tz.

date1 = DATETIME-TZ(STRING(TODAY) + " 09:10:00.000-0").

message QUOTER(date1).

Output in 4GL:

09/09/2025 09:10:00.000+00:00

Output put in FWD:

09/09/2025

This happens because the character.quoterWorker does not take into consideration the datetime and datetime-tz types.

#2 Updated by Eduard Soltan 11 months ago

  • Status changed from New to WIP

#4 Updated by Eduard Soltan 11 months ago

  • Status changed from WIP to Review
  • reviewer Constantin Asofiei added

Committed on 10538a, rev. 16154.

Use toStringMessage in qouterWorker in datetime and datetime-tz.

#5 Updated by Vladimir Tsichevski 11 months ago

  • Assignee set to Eduard Soltan
  • reviewer Vladimir Tsichevski added
  • reviewer deleted (Constantin Asofiei)

#6 Updated by Vladimir Tsichevski 11 months ago

  • reviewer Constantin Asofiei added
  • reviewer deleted (Vladimir Tsichevski)

#7 Updated by Vladimir Tsichevski 11 months ago

I did not notice Constantin is the reviewer already, and made review myself.

Eduard Soltan wrote:

Committed on 10538a, rev. 16154.

I suppose the revision is 16155.

Test Example

I've tested the change on the following example:

SESSION:SET-NUMERIC-FORMAT(",",".").
OUTPUT TO "out.txt".

DEFINE VARIABLE d AS DATE.
d = TODAY.
MESSAGE QUOTER(d).

DEFINE VARIABLE dt AS DATETIME.
dt = TODAY.
MESSAGE QUOTER(dt).

DEFINE VARIABLE dttz AS DATETIME-TZ.
dttz = TODAY.
MESSAGE QUOTER(dttz).

And the results match those for OE.

Issue

For date formats other than mdy, the date formatting is incorrect.

Consider the following modified example, where the date format is now ymd:

SESSION:SET-NUMERIC-FORMAT(",",".").
SESSION:DATE-FORMAT = 'ymd'.

OUTPUT TO "out.txt".

DEFINE VARIABLE d AS DATE.
d = TODAY.
MESSAGE STRING(d, "99/99/9999").
MESSAGE QUOTER(d).

DEFINE VARIABLE dt AS DATETIME.
dt = TODAY.
MESSAGE QUOTER(dt).

DEFINE VARIABLE dttz AS DATETIME-TZ.
dttz = TODAY.
MESSAGE QUOTER(dttz).

QUOTER(d) returns "25/09/09" instead of the expected "2025/09/09". Note that STRING(d, "99/99/9999") works correctly and results in 2025/09/09.

Other Notes

  • I think the change description is not perfectly clear. Something like: fixed: format "99/99/9999" was used also to format datetime and datetime-tz values.
  • I think the line does not look nice:
             else if (var instanceof date && !(var instanceof datetime || var instanceof datetimetz))
    

    Something like this is more clear:
             else if ("date".equals(var.getTypeName()))
    
  • Also, the cast to the date here is not necessary:
                date dateVar = (date) var;
                sb.append(dateVar.toString("99/99/9999"));
    

    and the code may look like this:
                sb.append(var.toString("99/99/9999"));
    

#8 Updated by Eduard Soltan 10 months ago

Vladimir Tsichevski wrote:

QUOTER(d) returns "25/09/09" instead of the expected "2025/09/09". Note that STRING(d, "99/99/9999") works correctly and results in 2025/09/09.

This is when you use toStringMessage method to format date variables, instead of toString("99/99/9999")?

Committed review issues on 10538a, rev. 16156.

#9 Updated by Constantin Asofiei 10 months ago

  • % Done changed from 0 to 100

Vladimir, thanks for the review; do you have any other concerns? Otherwise, we can put this into test.

#10 Updated by Constantin Asofiei 10 months ago

  • Status changed from Review to Merge Pending

Eduard, please merge after 10381a.

#11 Updated by Eduard Soltan 10 months ago

  • Status changed from Merge Pending to Test

10538a was merged to trunk rev. 16199 and archived.

Also available in: Atom PDF