qorelanguage / qore

Qore Programming Language
GNU General Public License v2.0
61 stars 10 forks source link

Timezone::date(string) is broken and always returns a date in the current time zone instead of the time zone of the object #584

Closed tethal closed 8 years ago

tethal commented 8 years ago

My timezone is set to UTC:

Failed tests:
./examples/test/qore/vars/date.qtest
./examples/test/qlib/FixedLengthUtil/transition_check_iterator.qtest
./examples/test/qlib/FixedLengthUtil/FixedLengthFileIterator.qtest
./examples/test/qlib/FixedLengthUtil/FixedLengthDataIterator.qtest
./examples/test/qlib/FixedLengthUtil/FixedLengthUtil.qtest

For example:

vagrant@vagrant-ubuntu-wily-64:~/src/qore/git/qore$ ./qore ./examples/test/qore/vars/date.qtest
QUnit Test "DateTest" v1.0
FAILURE: TimeZoneTests: 5 assertions, 4 succeeded
Assertion failure at ./examples/test/qore/vars/date.qtest:214
-----
        >> Expected: 7200, Actual: 0
-----
Ran 2 test cases, 1 succeeded, 1 error (362 assertions, 361 succeeded)

Or:

vagrant@vagrant-ubuntu-wily-64:~/src/qore/git/qore$ ./qore ./examples/test/qlib/FixedLengthUtil/transition_check_iterator.qtest
QUnit Test "transition_check_iterator" v1.0
FAILURE: transition check: 4 assertions, 3 succeeded
Assertion "line 2 content check" failure at ./examples/test/qlib/FixedLengthUtil/transition_check_iterator.qtest:65
-----
        >> Expected:
        >>      --------------------
        >>      hash: (2 members)
        >>        type : "type2"
        >>        record : hash: (3 members)
        >>          col3 : "c"
        >>          col4 : "ddd"
        >>          col5 : 2014-12-31 00:00:00.000000 Wed Z (UTC)
        >>      --------------------
        >> Actual:
        >>      --------------------
        >>      hash: (2 members)
        >>        type : "type2"
        >>        record : hash: (3 members)
        >>          col3 : "c"
        >>          col4 : "ddd"
        >>          col5 : 2014-12-31 00:00:00.000000 Wed +01:00 (CET)
        >>      --------------------
        >> Details:
        >>      --------------------
        >>      The values of .record.col5 differ:
        >>          expected: 2014-12-31 00:00:00.000000 Wed Z (UTC) (date)
        >>            actual: 2014-12-31 00:00:00.000000 Wed +01:00 (CET) (date)
        >>      --------------------
-----
Ran 1 test case, 1 error (4 assertions, 3 succeeded)
omusil24 commented 8 years ago

I fixed the FixedLengthUtil tests but I'd say that the date.qtest problem is a bug. @davidnich What's your opinion?

davidnich commented 8 years ago

@omusil24 I'll check it in a little bit- working on another fix now

davidnich commented 8 years ago

ex:

david@quasar:~/src/qore/git/qore/examples/test/qore/vars$ TZ=UTC qore -ne 'TimeZone tz("America/Chicago"); printf("%y\n", tz.date("1980-07-01", "YYYY-MM-DD").info());'
{relative: False, year: 1980, month: 7, day: 1, hour: 0, minute: 0, second: 0, microsecond: 0, dow: 2, doy: 183, utc_secs_east: -18000, dst: True, zone_name: "CDT", zone: {<TimeZone object>}}
david@quasar:~/src/qore/git/qore/examples/test/qore/vars$ TZ=UTC qore -ne 'TimeZone tz("America/Chicago"); printf("%y\n", tz.date("1980-07-01").info());'
{relative: False, year: 1980, month: 7, day: 1, hour: 0, minute: 0, second: 0, microsecond: 0, dow: 2, doy: 183, utc_secs_east: 0, dst: False, zone_name: "UTC", zone: {<TimeZone object>}}