@@ -32,6 +32,40 @@ function packVariable(dfg::G, v::DFGVariable)::Dict{String, Any} where G <: Abst
32
32
return props
33
33
end
34
34
35
+ # Corrects any `::ZonedDateTime` fields of T in corresponding `interm::Dict` as `dateformat"yyyy-mm-ddTHH:MM:SS.ssszzz"`
36
+ function standardizeZDTString! (T, interm:: Dict )
37
+ @debug " About to look through types of" T
38
+ for (name, typ) in zip (fieldnames (T), T. types)
39
+ # @debug "name=$name"
40
+ # @debug "typ=$typ"
41
+ if typ <: ZonedDateTime
42
+ # Make sure that the timestamp is correctly formatted with subseconds
43
+ namestr = string (name)
44
+ @debug " must ensure SS.ssszzz on $name :: $typ -- $(interm[namestr]) "
45
+ # # FIXME copy #588, but doesnt work: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/582#issuecomment-671884668
46
+ # # E.g.: interm[namestr] = replace(interm[namestr], r":(\d)(\d)(Z|z|\+|-)" => s":\1\2.000\3") = "2020-08-11T04:05:59.82-04:00"
47
+ # @show interm[namestr] = replace(interm[namestr], r":(\d)(\d)(Z|z|\+|-)" => s":\1\2.000\3")
48
+ # @debug "after SS.ssszzz -- $(interm[namestr])"
49
+ # # DROP piece below once this cleaner copy #588 is working
50
+ supersec, subsec = split (interm[namestr], ' .' )
51
+ sss, zzz = split (subsec, ' -' )
52
+ # @debug "split time elements are $sss-$zzz"
53
+ # make sure milliseconds portion is precisely 3 characters long
54
+ if length (sss) < 3
55
+ # pad with zeros at the end
56
+ while length (sss) < 3
57
+ sss *= " 0"
58
+ end
59
+ newtimessszzz = supersec* " ." * sss* " -" * zzz
60
+ @debug " new time string: $newtimessszzz "
61
+ # reassembled ZonedDateTime is put back in the dict
62
+ interm[namestr] = newtimessszzz
63
+ end
64
+ end
65
+ end
66
+ nothing
67
+ end
68
+
35
69
function unpackVariable (dfg:: G ,
36
70
packedProps:: Dict{String, Any} ;
37
71
unpackPPEs:: Bool = true ,
@@ -85,10 +119,12 @@ function unpackVariable(dfg::G,
85
119
end
86
120
87
121
for (k,bdeInter) in dataIntermed
88
- @show label
89
- @show bdeInter
122
+ # @debug " label=$label"
123
+ # @debug " bdeInter=$bdeInter"
90
124
interm = JSON. parse (bdeInter)
91
- Unmarshal. unmarshal (getfield (DistributedFactorGraphs, dataElemTypes[k]), interm)
125
+ objType = getfield (DistributedFactorGraphs, dataElemTypes[k])
126
+ standardizeZDTString! (objType, interm)
127
+ fullVal = Unmarshal. unmarshal (objType, interm)
92
128
variable. dataDict[k] = fullVal
93
129
end
94
130
end
0 commit comments