Timestamp subtraction ignores seconds
I am trying to calculate duration given two timestamps. When I subtract the two, it appears the subtraction is happening with minute-level granularity (i.e. the seconds are being ignored). Is this the correct subtraction functionality?
Here's a comparison I have done trying to subtract various time intervals...
a!localVariables(
local!epsilon: 0.0000115740740740741, /* one second */
local!times: {
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:00:00 AM", expected: 0 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:00:01 AM", expected: local!epsilon },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:00:10 AM", expected: local!epsilon * 10 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:00:30 AM", expected: local!epsilon * 30 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:00:50 AM", expected: local!epsilon * 50 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:00:59 AM", expected: local!epsilon * 59 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:00:59.999 AM", expected: local!epsilon * 59.999 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:01:00 AM", expected: local!epsilon * 60 * 1 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:01:30 AM", expected: local!epsilon * 60 * 1.5 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:02:00 AM", expected: local!epsilon * 60 * 2 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:04:00 AM", expected: local!epsilon * 60 * 4 },
{ start: "1/1/2000 8:00:00 AM", end: "1/1/2000 8:08:00 AM", expected: local!epsilon * 60 * 8 }
},
a!forEach(
items: local!times,
expression: a!localVariables(
local!actual: toDateTime(fv!item.end) - toDateTime(fv!item.start),
local!actualNumeric: todecimal(local!actual),
{
expected: tointervalds(fv!item.expected),
actual: local!actual,
nearlySame: abs(local!actualNumeric - todecimal(fv!item.expected)) < local!epsilon
}
)
)
)
All of these should result in nearlySame being true. But only the ones that are quantized to the minute boundary end up being true.


