Closed Bug 603159 Opened 14 years ago Closed 14 years ago

implement exslt-date:date-time()

Categories

(Core :: XSLT, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: julian.reschke, Unassigned)

References

()

Details

Attachments

(1 file, 3 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 (.NET CLR 3.5.30729) Build Identifier: 3.6.10 The EXSLT date-time module contains many functions (http://www.exslt.org/date/index.html). However, implementing just date-time() out of these would be very useful, because it enables XSLTs to get the current system date (something that currently can't done at all). Reproducible: Always Steps to Reproduce: Navigate to http://greenbytes.de/tech/webdav/xslt-test.xml Actual Results: "Date-Time Support exslt:date-time(): No" Expected Results: "Date-Time Support exslt:date-time(): Yes, and returns: 2010-10-10T09:40:29.095+01:00" (with the current date)
1) the string handling probably should be double-checked 2) is there a canonical place for a test case?
Attachment #482123 - Flags: review?(peterv)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Having date-time() would certainly be useful. I hope it can happen.
Any chance to get this into FF5?
The test case is very minimal in that it only compares the prefix of the generated string (the year), but at least the extension function gets called.
Attachment #482123 - Attachment is obsolete: true
Attachment #524949 - Flags: review?(jonas)
Attachment #482123 - Flags: review?(peterv)
Use nsPrintfCString and CopyASCIItoUTF16 instead (yes, our string classes are not easy to use). You can see how the generate-id function is implemented here: http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xslt/txGenerateIdFunctionCall.cpp?force=1#83 http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp#616 Also, is the string returned from this function parsable using the Date object in javascript? If so, it might be nicer to do so and check that the difference to Date.now() is less than, say, 30 minutes.
(In reply to comment #5) > Use nsPrintfCString and CopyASCIItoUTF16 instead (yes, our string classes are > not easy to use). > > You can see how the generate-id function is implemented here: > > http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xslt/txGenerateIdFunctionCall.cpp?force=1#83 > http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp#616 Will do. > Also, is the string returned from this function parsable using the Date object > in javascript? If so, it might be nicer to do so and check that the difference > to Date.now() is less than, say, 30 minutes. I tried that last week and got an exception. I didn't investigate further as the the documentation on the 8601 aspect on Date.parse is a bit weak. It would be good to know what exactly it *is* expected to parse.
Attachment #524949 - Attachment is obsolete: true
Attachment #526998 - Flags: review?
Attachment #526998 - Flags: review? → review?(jonas)
(In reply to comment #6) > (In reply to comment #5) > > Use nsPrintfCString and CopyASCIItoUTF16 instead (yes, our string classes are > > not easy to use). > > > > You can see how the generate-id function is implemented here: > > > > http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xslt/txGenerateIdFunctionCall.cpp?force=1#83 > > http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp#616 > > Will do. Done. > > Also, is the string returned from this function parsable using the Date object > > in javascript? If so, it might be nicer to do so and check that the difference > > to Date.now() is less than, say, 30 minutes. > > I tried that last week and got an exception. I didn't investigate further as > the the documentation on the 8601 aspect on Date.parse is a bit weak. It would > be good to know what exactly it *is* expected to parse. I retried and got it working (I think I assumed wrong that Date.parse returns a Date). Set the accepted diff to 30 minutes as suggested.
Comment on attachment 526998 [details] [diff] [review] implementation of exslt:date-time(), plus a minimal test case >+ // http://exslt.org/date/functions/date-time/ >+ // format: YYYY-MM-DDTTHH:MM:SS.sss+00:00 >+ char formatstr[] = "%04hd-%02ld-%02ldT%02ld:%02ld:%02ld.%03ld%c%02ld:%02ld"; >+ size_t max = sizeof("YYYY-MM-DDTHH:MM:SS.sss+00:00"); Make this |const size_t max|. >+ ok(now_ms - xslt_ms < accepted_diff, "generated timestamp should be not more than " >+ + accepted_diff + " ms before 'now', but the difference was: " + (now_ms - xslt_ms)); This needs to be Math.abs(now_ms - xslt_ms), in both places. r=me with those fixed. If you attach a new patch (preferrably "hg export"ed) then I can land it.
Attachment #526998 - Flags: review?(jonas) → review+
(In reply to comment #10) > Comment on attachment 526998 [details] [diff] [review] > implementation of exslt:date-time(), plus a minimal test case > > > >+ // http://exslt.org/date/functions/date-time/ > >+ // format: YYYY-MM-DDTTHH:MM:SS.sss+00:00 > >+ char formatstr[] = "%04hd-%02ld-%02ldT%02ld:%02ld:%02ld.%03ld%c%02ld:%02ld"; > >+ size_t max = sizeof("YYYY-MM-DDTHH:MM:SS.sss+00:00"); > > Make this |const size_t max|. Will do. > >+ ok(now_ms - xslt_ms < accepted_diff, "generated timestamp should be not more than " > >+ + accepted_diff + " ms before 'now', but the difference was: " + (now_ms - xslt_ms)); > > This needs to be Math.abs(now_ms - xslt_ms), in both places. Really? isn't now_ms guaranteed to be >= xslt_ms? Anyway; I'll make that change...
Attachment #526998 - Attachment is obsolete: true
Attachment #528302 - Flags: review?(jonas)
Any chance to get this in before FF6 Aurora is branched?
Yup, checked in. Leaving the honors of marking it fixed to Julian. (btw, the patch here contained windows lineendings which made it not apply. Easy fix though).
(In reply to comment #15) > Yup, checked in. Leaving the honors of marking it fixed to Julian. Thanks. I build the Nightly from m-c and tested against http://greenbytes.de/tech/webdav/xslt-test.xml and all is well. > (btw, the patch here contained windows lineendings which made it not apply. > Easy fix though). Sorry for that.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
OS: Windows 7 → All
Hardware: x86 → All
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: