Skip to content

Commit

Permalink
refactor unicsv & xcsv date time handling (#1114)
Browse files Browse the repository at this point in the history
* refactor unicsv date time handling.

* restrict utc option range to match Qt offsetfromutc

* move xcsv from C-style legacy time to Qt.

* fill in lower order date/time fields when parsing.

* don't return date/time if we don't have one!

* enhance xcsv date/time testing, fix bug.

* csv format date time adjustements.

use QDateTime::fromString to parse iso date times.
return invalid QTime from addhms if parsing fails entirely.

* datetime display fixes.

For the xcsv writer:
avoid priting date/time fields when there isn't a valid date/time.
when printing with am/pm use times from a 12 hour clock.
add support for printing dotnet time.
use QDateTime::toString to print ISO time.
For the xcsv and unicsv readers:
use QDateTime::fromString instead of xml_parse_time when reading
ISO datetimes.  This avoids xml_parse_times intentional odd behavior
of treating non-timezoned times as UTC.

add a test of the xcsv writer time related fields.  This only runs
in America/Denver time zone.  As setting the time zone is system
dependent the test only runs if tzselect is available.  If so it
assumes America/Denver is available.

correct documentation to give a sensible format for xcsv field GMT_TIME.

* add reference files for new test.

* silence xcsv reader conversion warnings on empty strings.

* warn on parse errors reading excel time.

* xcsv date/time fixes.

fix addhms to account for 12/24 hour clock.
don't print invalid datetimes with iso_time, iso_time_ms.

add testcases to exercise all the xcsv reader date/time flavors.

* clarify HMSL, HMSG wrt 12/24 hour clocks.

* add missing reference file.

* enhance xcsv for HMS[L|G] before or after [LOCAL|GMT]_TIME

* restore YYYYYMMDD to use UTC.

This has been broken for some time.  Mail from 2012 indicates the intent
was UTC (https://sourceforge.net/p/gpsbabel/mailman/message/29544538/)

* unicsv review catches

don't ripple into trouble with msec rounding.
pass outputs that may or may not be written as references.

* retire xcsv fields HMSG_TIME, HMSL_TIME.

This is potentially a user visible change.  It could require
users to rewrite any style files they have created that use
these fields.

These are replaced by repeated use of GMT_TIME and LOCAL_TIME.
This eliminates our pain over 12/24 hour clock issues. strptime/
strftime (as well as QTime) have distinct conversion specifiers
for hours with 12/24 hour clocks.  Our support for HMSG_TIME,
HMSL_TIME used integer conversion specifiers for hours, minutes
and seconds.  This made it difficult to decide if a 12 or 24 hour
clock should be used, and made it impossible to have reduced
precision values with 12 hour clock using an AM/PM designation.
We also always printed AM/PM designations.

* fix whitespace in serialization reference file
  • Loading branch information
tsteven4 authored and robertlipe committed Aug 12, 2024
1 parent 807de8d commit aada285
Show file tree
Hide file tree
Showing 10 changed files with 1,841 additions and 50 deletions.
251 changes: 251 additions & 0 deletions .cmake/api/v1/reply/codemodel-v2-401241073bdb4191c181.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
{
"configurations" :
[
{
"directories" :
[
{
"build" : ".",
"childIndexes" :
[
1
],
"jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json",
"minimumCMakeVersion" :
{
"string" : "3.16"
},
"projectIndex" : 0,
"source" : ".",
"targetIndexes" :
[
0,
4,
5,
6,
7,
13,
15,
16,
17
]
},
{
"build" : "gui",
"childIndexes" :
[
2
],
"jsonFile" : "directory-gui-Debug-748b39b5a140a70fe5f8.json",
"minimumCMakeVersion" :
{
"string" : "3.16"
},
"parentIndex" : 0,
"projectIndex" : 0,
"source" : "gui",
"targetIndexes" :
[
8,
9,
10,
11,
12,
14
]
},
{
"build" : "gui/coretool",
"jsonFile" : "directory-gui.coretool-Debug-87963545341ba97be176.json",
"minimumCMakeVersion" :
{
"string" : "3.16"
},
"parentIndex" : 1,
"projectIndex" : 0,
"source" : "gui/coretool",
"targetIndexes" :
[
1,
2,
3
]
}
],
"name" : "Debug",
"projects" :
[
{
"directoryIndexes" :
[
0,
1,
2
],
"name" : "gpsbabel",
"targetIndexes" :
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17
]
}
],
"targets" :
[
{
"directoryIndex" : 0,
"id" : "check::@6890427a1f51a3e7e1df",
"jsonFile" : "target-check-Debug-66ec132d781236ee90e7.json",
"name" : "check",
"projectIndex" : 0
},
{
"directoryIndex" : 2,
"id" : "coretool::@59ad487847001a1eac72",
"jsonFile" : "target-coretool-Debug-00000000000000000000.json",
"name" : "coretool",
"projectIndex" : 0
},
{
"directoryIndex" : 2,
"id" : "coretool_lrelease::@59ad487847001a1eac72",
"jsonFile" : "target-coretool_lrelease-Debug-71d6c78e389ca52f783a.json",
"name" : "coretool_lrelease",
"projectIndex" : 0
},
{
"directoryIndex" : 2,
"id" : "coretool_lupdate::@59ad487847001a1eac72",
"jsonFile" : "target-coretool_lupdate-Debug-68c815f83c50331f6566.json",
"name" : "coretool_lupdate",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "gpsbabel::@6890427a1f51a3e7e1df",
"jsonFile" : "target-gpsbabel-Debug-5d095b824e48fc189464.json",
"name" : "gpsbabel",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "gpsbabel.html::@6890427a1f51a3e7e1df",
"jsonFile" : "target-gpsbabel.html-Debug-396075575900ebd1300b.json",
"name" : "gpsbabel.html",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "gpsbabel.org::@6890427a1f51a3e7e1df",
"jsonFile" : "target-gpsbabel.org-Debug-48c1dcdc6a6d71b29e53.json",
"name" : "gpsbabel.org",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "gpsbabel.pdf::@6890427a1f51a3e7e1df",
"jsonFile" : "target-gpsbabel.pdf-Debug-873580379c2b9266e520.json",
"name" : "gpsbabel.pdf",
"projectIndex" : 0
},
{
"directoryIndex" : 1,
"id" : "gpsbabelfe::@35f413a6cfe5475b20aa",
"jsonFile" : "target-gpsbabelfe-Debug-00000000000000000000.json",
"name" : "gpsbabelfe",
"projectIndex" : 0
},
{
"directoryIndex" : 1,
"id" : "gpsbabelfe_autogen::@35f413a6cfe5475b20aa",
"jsonFile" : "target-gpsbabelfe_autogen-Debug-f7875ab99cea46dc8681.json",
"name" : "gpsbabelfe_autogen",
"projectIndex" : 0
},
{
"directoryIndex" : 1,
"id" : "gpsbabelfe_autogen_timestamp_deps::@35f413a6cfe5475b20aa",
"jsonFile" : "target-gpsbabelfe_autogen_timestamp_deps-Debug-b312ab01a4e1eee4b178.json",
"name" : "gpsbabelfe_autogen_timestamp_deps",
"projectIndex" : 0
},
{
"directoryIndex" : 1,
"id" : "gpsbabelfe_lrelease::@35f413a6cfe5475b20aa",
"jsonFile" : "target-gpsbabelfe_lrelease-Debug-873580379c2b9266e520.json",
"name" : "gpsbabelfe_lrelease",
"projectIndex" : 0
},
{
"directoryIndex" : 1,
"id" : "gpsbabelfe_lupdate::@35f413a6cfe5475b20aa",
"jsonFile" : "target-gpsbabelfe_lupdate-Debug-7b36a4643573de4d52d2.json",
"name" : "gpsbabelfe_lupdate",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "mkicondoc::@6890427a1f51a3e7e1df",
"jsonFile" : "target-mkicondoc-Debug-f6a7cab30f7685631ba5.json",
"name" : "mkicondoc",
"projectIndex" : 0
},
{
"directoryIndex" : 1,
"id" : "package_app::@35f413a6cfe5475b20aa",
"jsonFile" : "target-package_app-Debug-cd50a91ebf55fbad934a.json",
"name" : "package_app",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "shp::@6890427a1f51a3e7e1df",
"jsonFile" : "target-shp-Debug-fa8203e835cabd237ccc.json",
"name" : "shp",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "usb-1.0::@6890427a1f51a3e7e1df",
"jsonFile" : "target-usb-1.0-Debug-a5fef3c0abe84d658ab3.json",
"name" : "usb-1.0",
"projectIndex" : 0
},
{
"directoryIndex" : 0,
"id" : "z::@6890427a1f51a3e7e1df",
"jsonFile" : "target-z-Debug-65d21bc79c988468bacf.json",
"name" : "z",
"projectIndex" : 0
}
]
}
],
"kind" : "codemodel",
"paths" :
{
"build" : "/Users/robertlipe/src/gpsbabel",
"source" : "/Users/robertlipe/src/gpsbabel"
},
"version" :
{
"major" : 2,
"minor" : 6
}
}
108 changes: 108 additions & 0 deletions .cmake/api/v1/reply/index-2024-08-12T02-32-33-0475.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"cmake" :
{
"generator" :
{
"multiConfig" : false,
"name" : "Unix Makefiles"
},
"paths" :
{
"cmake" : "/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake",
"cpack" : "/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cpack",
"ctest" : "/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/ctest",
"root" : "/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.28"
},
"version" :
{
"isDirty" : false,
"major" : 3,
"minor" : 28,
"patch" : 1,
"string" : "3.28.1",
"suffix" : ""
}
},
"objects" :
[
{
"jsonFile" : "codemodel-v2-401241073bdb4191c181.json",
"kind" : "codemodel",
"version" :
{
"major" : 2,
"minor" : 6
}
},
{
"jsonFile" : "cache-v2-00000000000000000000.json",
"kind" : "cache",
"version" :
{
"major" : 2,
"minor" : 0
}
},
{
"jsonFile" : "cmakeFiles-v1-00000000000000000000.json",
"kind" : "cmakeFiles",
"version" :
{
"major" : 1,
"minor" : 0
}
},
{
"jsonFile" : "toolchains-v1-96ce99ee7930729e1e18.json",
"kind" : "toolchains",
"version" :
{
"major" : 1,
"minor" : 0
}
}
],
"reply" :
{
"cache-v2" :
{
"jsonFile" : "cache-v2-00000000000000000000.json",
"kind" : "cache",
"version" :
{
"major" : 2,
"minor" : 0
}
},
"cmakeFiles-v1" :
{
"jsonFile" : "cmakeFiles-v1-00000000000000000000.json",
"kind" : "cmakeFiles",
"version" :
{
"major" : 1,
"minor" : 0
}
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-401241073bdb4191c181.json",
"kind" : "codemodel",
"version" :
{
"major" : 2,
"minor" : 6
}
},
"toolchains-v1" :
{
"jsonFile" : "toolchains-v1-96ce99ee7930729e1e18.json",
"kind" : "toolchains",
"version" :
{
"major" : 1,
"minor" : 0
}
}
}
}
Loading

0 comments on commit aada285

Please sign in to comment.