Comments (13)
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
To not break existing rounding (which was added to work around timezone confusion issues),
I have added two new JR functions:
date-time(x)
-- equivalent to date(x), but retains the time.
format-date-time(x, formatstr)
-- equivalent to format-date(x, formatstr) but retains time of 'x'.
Reported by mitchellsundt
on 2013-06-21 21:48:43
- Labels added: Collect, Validate, Aggregate, Briefcase
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
So if you want to refer to a dateTime field, you should always refer to it as date-time(fieldname)?
Otherwise, you lose the time part?
Reported by chrislrobert
on 2013-06-22 07:50:43
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Frustrating. Looked into this further -- my fix is incomplete. date arithmetic that
preserves times is very badly broken.
I'm not sure there is a backward-compatible solution, as the changes would need to
be made within the DateUtils class, and toNumeric() and several other areas where dates
are truncated to date values. These all seem to be kludges for the time zone being
ill-defined.
date-time(x) was intended to convert any non-date value 'x' into a Date, preserving
the time. This is simply not working because of the rounding within the methods it
relies on.
format-date-time(x,fmt) will format any date value 'x' into a string, with the time
preserved (vs. set to 00:00:00.000 for format-date(...)).
But this has limited utility because any arithmetic on a date will wipe the time.
Reported by mitchellsundt
on 2013-06-24 17:46:05
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Ideally, the data type of the field (dateTime vs. date) could be used to determine whether
to retain the time portion of the value. Then users could get the old rounding behavior
using type="date" and get the behavior retaining the time by using type="dateTime".
But I think that is a bigger fix. It is also where I think the current evaluation logic
is incorrect.
Reported by mitchellsundt
on 2013-06-24 21:30:48
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Looking at the raft of recent changes to this code, I fully expected this to work now.
However, there is still a problem with calculate fields being stripped of their times.
(Perhaps it's a minor problem.) Here's an example, where "birthhour" is a datetime
field in an earlier repeat group named "names". The slashes separate the type, name,
and calculation columns in an XLSForm:
calculate / birthhourfromearlier / indexed-repeat(${birthhour}, ${names}, position(..))
calculate / helperlabelhour / format-date-time(${birthhourfromearlier}, '%Y-%b-%e %H:%M:%S')
The second field, in this example, always has 00:00:00 for the time. However, this
works:
calculate / helperlabelhour2 / format-date-time(indexed-repeat(${birthhour}, ${names},
position(..)), '%Y-%b-%e %H:%M:%S')
In this case, the time is not lost. The only difference is that the first case goes
datetime->calculate->formatting whereas the second goes datetime->formatting.
It's not obvious to me where the time is being lost, because Recalculate.wrapData()
now appears to be returning a datetime object for datetime fields. I am happy to investigate
further, but wanted to check first: is this behavior now by design, and/or was a fix
for this case not intended due to compatibility concerns, etc.? I don't want to spend
time tracing the issue if this is now intentional behavior. Thanks!
Reported by chrislrobert
on 2013-07-29 22:19:25
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
By the way, in my example, the birthhourfromearlier field contains just the date (not
even 00:00:00, just "2013-07-29" for, e.g., today). That would seem to imply that,
the datetime field, when converted to a string for display, had no time (and thus went
into the calculate field with no time... so that format-date-time had no time to format
later on). And indeed, if you reference ${birthhour} directly within its repeat group,
you get just the date. So that seems likely the source of the trouble.
From the code, it looks like the display string for datetime fields should be including
the time (via DateUtils.formatDateTime), but clearly something is going wrong somewhere.
Again, I'm happy to trace further if somebody thinks it's worth while (i.e., if this
isn't by design). Thanks.
Reported by chrislrobert
on 2013-07-29 22:37:52
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
I hate this code. I hate this code. I hate this code.
Yes, this is definitely does not work-as-intended.
FYI, the calculate expression is held/managed by
org.javarosa.core.model.condition.Recalculate
I'd love it if you can investigate this.
Reported by mitchellsundt
on 2013-07-30 16:59:43
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Okay, we've been delayed here due to our v1.15 release. But I'm slowly investigating.
The date and time display correctly when you edit a form, so the DateTimeData.getDisplayText()
appears to be doing its job. When you refer to the field with ${fieldname}, though,
it drops the time. So it's just a matter of figuring out where that convert-to-string
is happening, and why it doesn't include the time. If it's fixed there, it might also
solve the datetime->calculate issue.
Reported by chrislrobert
on 2013-08-07 19:49:23
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Okay, so much for simplifying assumptions: there are at least two (very similar) problems
here:
1. XPathFuncExpr.toString() doesn't distinguish between date and datetime fields since
they both appear as "instanceof Date". It assumes just a date and formats accordingly
-- so times are lost if you call string(${field}) where field is a datetime field.
2. Recalculate.wrapData() looks like it should work for putting datetime values into
calculate fields, but it still won't work because the target dataType is not datetime
(it's probably string for a calculate field). Thus, again, the code sees "instanceof
Date", sees that the target dataType is NOT DATATYPE_DATE_TIME or DATATYPE_TIME, so
it assumes just a date.
There is almost certainly at least a third case: when ${datetimefield} is included
in a label, code somewhere has to convert datetimefield to a string (to add it to the
label). It may call XPathFuncExpr.toString(), but I sincerely doubt it.
So, pretty much anywhere a Date object is converted to a string, we have problems whereby
times are lost. Two cases are above, there is almost certainly a third case, and there
may be more.
Fun, eh?
Reported by chrislrobert
on 2013-08-07 20:11:09
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Issue 855 has been merged into this issue.
Reported by mitchellsundt
on 2013-10-03 19:06:41
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Issue 630 has been merged into this issue.
Reported by mitchellsundt
on 2013-10-03 19:06:51
from aggregate.
Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:25 GMT
Issue 808 has been merged into this issue.
Reported by mitchellsundt
on 2013-10-03 19:07:13
from aggregate.
Attention! We're housekeeping! This issue will automatically be closed if no feedback is received in one week.
If this issue is important to you or you can provide more information about it, please, do so as soon as possible :)
from aggregate.
Related Issues (20)
- Incorrect war file in v2.0.3 release HOT 2
- Geotrace and Geoshape points are lost because of the maximum number of characters is 255 HOT 1
- User without a password cause a 500 when authenticating
- Geotrace and Geoshape points are lost because of the maximum number of characters is 255 HOT 2
- Login credentials are cached in Briefcase-Aggregate cooperation. HOT 1
- Audit.csv activated but not viewable in aggregate HOT 1
- Had to fix Util.groovy setPropertiesValue for "./gradlew clean dockerComposeBuild -xtest -PwarMode=complete" HOT 2
- Database corruption HOT 1
- Submissions of form with Annotate widget/Signature widget with default image described are marked as incomplete.
- ODK-Aggregate-v1.7.4-Windows.exe.zip contains no windows code HOT 1
- Don't send users to Github issues
- Initial login fails when no internet connection
- Can't upload my XML file on the aggregate server HOT 1
- Exporting an Xml form HOT 2
- cloud-config aggregate-cli command puts log at root
- Publishing to Google Sheet is broken
- Making Cookies HTTPOnly HOT 4
- Session cookie name parameter HOT 1
- Session Hijacking Prevention
- Could not determine java version from '11.0.10' (after running `./gradlew appRunWar` command)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aggregate.