Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicsv has inconsistent handling of date+time, date only, and time only fields #1097

Open
tsteven4 opened this issue May 1, 2023 · 0 comments

Comments

@tsteven4
Copy link
Collaborator

tsteven4 commented May 1, 2023

We have numerous inconsistencies related to partial date & time information in unicsv.
Perhaps we should store a date only as an invalid QDateTime with a valid QDate, and invalid QTime, and an indeterminate Qt::TimeSpec.
Perhaps we should store a time only as an invalid QDateTime with a invalid QDate, a valid Qtime, and an indetrminate Qt::TimeSpec.

unicsv interprets a date only as relative to UTC start of day and displays it translated to local time.
unicsv interprets a date and time as relative to local time.
unicsv regards zero time without date as invalid.
unicsv echos a non zero time without date as relative to the unix epoch and displays it translated to local time.

a date alone is interpreted as UTC start of day.
a date and time is interpreted as local
a time alone is interpreted as relative to the unix epoch

$ cat datetime.txt
name, lat, lon, date, time
dateonly, 36, -87, 2008-08-12,
dateandtime, 36, -87, 2008-08-12, 00:00:00
timeonly,36, -87, , 00:00:00
timeonly,36, -87, , 00:00:01
dateonly, 36, -87, 2008-12-12,
dateandtime, 36, -87, 2008-12-12, 00:00:00
timeonly,36, -87, , 00:00:00
timeonly,36, -87, , 00:00:01
$ cat xx
#!/bin/bash
cat datetime.txt;
TZ=/usr/share/zoneinfo/America/Denver ../../codeanalysis/bld/gpsbabel  -i unicsv -f datetime.txt -x transform,wpt=trk,del -o unicsv -F -
TZ=/usr/share/zoneinfo/America/Denver ../../codeanalysis/bld/gpsbabel  -i unicsv -f datetime.txt -x transform,wpt=trk,del -o gpx -F - | grep '\<time\>' | tail -6
TZ=/usr/share/zoneinfo/America/New_York ../../codeanalysis/bld/gpsbabel  -i unicsv -f datetime.txt -x transform,wpt=trk,del -o unicsv -F -
TZ=/usr/share/zoneinfo/America/New_York ../../codeanalysis/bld/gpsbabel  -i unicsv -f datetime.txt -x transform,wpt=trk,del -o gpx -F - | grep '\<time\>' | tail -6
$ ./xx
name, lat, lon, date, time
dateonly, 36, -87, 2008-08-12,
dateandtime, 36, -87, 2008-08-12, 00:00:00
timeonly,36, -87, , 00:00:00
timeonly,36, -87, , 00:00:01
dateonly, 36, -87, 2008-12-12,
dateandtime, 36, -87, 2008-12-12, 00:00:00
timeonly,36, -87, , 00:00:00
timeonly,36, -87, , 00:00:01
No,Latitude,Longitude,Name,Date,Time
1,36.000000,-87.000000,"dateonly",2008/08/11,18:00:00
2,36.000000,-87.000000,"dateandtime",2008/08/12,00:00:00
3,36.000000,-87.000000,"timeonly",,
4,36.000000,-87.000000,"timeonly",,17:00:01
5,36.000000,-87.000000,"dateonly",2008/12/11,17:00:00
6,36.000000,-87.000000,"dateandtime",2008/12/12,00:00:00
7,36.000000,-87.000000,"timeonly",,
8,36.000000,-87.000000,"timeonly",,17:00:01
    <time>2008-08-12T00:00:00Z</time>
    <time>2008-08-12T06:00:00Z</time>
    <time>1970-01-01T00:00:01Z</time>
    <time>2008-12-12T00:00:00Z</time>
    <time>2008-12-12T07:00:00Z</time>
    <time>1970-01-01T00:00:01Z</time>
No,Latitude,Longitude,Name,Date,Time
1,36.000000,-87.000000,"dateonly",2008/08/11,20:00:00
2,36.000000,-87.000000,"dateandtime",2008/08/12,00:00:00
3,36.000000,-87.000000,"timeonly",,
4,36.000000,-87.000000,"timeonly",,19:00:01
5,36.000000,-87.000000,"dateonly",2008/12/11,19:00:00
6,36.000000,-87.000000,"dateandtime",2008/12/12,00:00:00
7,36.000000,-87.000000,"timeonly",,
8,36.000000,-87.000000,"timeonly",,19:00:01
    <time>2008-08-12T00:00:00Z</time>
    <time>2008-08-12T04:00:00Z</time>
    <time>1970-01-01T00:00:01Z</time>
    <time>2008-12-12T00:00:00Z</time>
    <time>2008-12-12T05:00:00Z</time>
    <time>1970-01-01T00:00:01Z</time>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant