Thread: [Xsltforms-support] A curious problem with the date picker - odd months!
Brought to you by:
alain-couthures
From: Philip F. <Phi...@ma...> - 2011-06-08 12:47:55
|
Hello, There appears to be a very curious bug with the date picker that only shows itself under certain circumstances. Here is how to recreate it: 1) Ensure the date of your computer is set to a calendar month that has an odd number e.g. May (yes really!). I used the date 31/05/2011. 2) Open a form (see below for included test case) and using the date picker widget set the date to 21st of February (21/02/2011) in the 'Test Date' control. Notice that the month in the date field is set to March 21/03/2011 and not 21/02/2011 as selected. Now to prove that this is related to the machine's calendar month, go and change the month back to June (an even month), do things like clear the browsers cache and repeat the test. You will see that the month does change this time. I have found this with the 494 release (because I'm using eXSLTForms and its Rich Text Editor widgets) in Firefox 3.6.10 on Windows 7 and it is still happening with the 503 release. Regards Philip Fennell Consultant MarkLogic Corporation Phone +44 (0) 203 402 3619 | Mobile +44 (0) 7824 830 866 email Phi...@ma...<mailto:Fir...@ma...> web www.marklogic.com<http://www.marklogic.com/> This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="/resource/xsltforms/xsltforms.xsl" type="text/xsl"?> <html xml:lang="en" lang="en" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Date Widget Test</title> <xf:model> <xf:action ev:event="xforms-ready"> <xf:setvalue ref="instance('test')/date" value="substring-before(now(), 'T')"/> </xf:action> <xf:bind id="testDate" nodeset="instance('test')/date" type="date"/> <xf:instance id="test"> <data> <date/> </data> </xf:instance> </xf:model> </head> <body> <div> <h1>Date Widget Test</h1> <xf:input bind="testDate"> <xf:label>Test Date</xf:label> </xf:input> </div> </body> </html> |
From: Philip F. <Phi...@ma...> - 2011-06-10 12:36:09
|
I believe I have the answer to this strange problem. In the Calendar() function, at line 5575 of xsltforms.js, the month is set with: date.setMonth(cal.selectMonth.value); however, the setMonth method of the Date object can accept to parameters: monthValue and dayValue. When dayValue is missing the date value from getDate is used. When the current date's month value is greater that the largest day value for the target month the setMonth method will attempt to correct the month accordingly. Therefore, in my test case of setting a target date of February 21st on the date of May 31st, the getDate method will return 31st which is outside of the range for February (max 29th) and so it adds the difference and rolls the month over into March. This behaviour is documented in the JavaScript Reference: 'If a parameter you specify is outside of the expected range, setMonth attempts to update the date information in the Date object accordingly. For example, if you use 15 for monthValue, the year will be incremented by 1 (year + 1), and 3 will be used for month.' The way I have solved the problem is to change line 5575 to this: date.setMonth(cal.selectMonth.value, cal.day); Regards Philip Fennell Consultant MarkLogic Corporation Phone +44 (0) 203 402 3619 | Mobile +44 (0) 7824 830 866 email Phi...@ma...<mailto:Fir...@ma...> web www.marklogic.com<http://www.marklogic.com/> This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation From: Philip Fennell [mailto:Phi...@ma...] Sent: Wednesday, June 08, 2011 1:47 PM To: support xsltforms Subject: [Xsltforms-support] A curious problem with the date picker - odd months! Hello, There appears to be a very curious bug with the date picker that only shows itself under certain circumstances. Here is how to recreate it: 1) Ensure the date of your computer is set to a calendar month that has an odd number e.g. May (yes really!). I used the date 31/05/2011. 2) Open a form (see below for included test case) and using the date picker widget set the date to 21st of February (21/02/2011) in the 'Test Date' control. Notice that the month in the date field is set to March 21/03/2011 and not 21/02/2011 as selected. Now to prove that this is related to the machine's calendar month, go and change the month back to June (an even month), do things like clear the browsers cache and repeat the test. You will see that the month does change this time. I have found this with the 494 release (because I'm using eXSLTForms and its Rich Text Editor widgets) in Firefox 3.6.10 on Windows 7 and it is still happening with the 503 release. Regards Philip Fennell Consultant MarkLogic Corporation Phone +44 (0) 203 402 3619 | Mobile +44 (0) 7824 830 866 email Phi...@ma...<mailto:Fir...@ma...> web www.marklogic.com<http://www.marklogic.com/> This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="/resource/xsltforms/xsltforms.xsl" type="text/xsl"?> <html xml:lang="en" lang="en" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Date Widget Test</title> <xf:model> <xf:action ev:event="xforms-ready"> <xf:setvalue ref="instance('test')/date" value="substring-before(now(), 'T')"/> </xf:action> <xf:bind id="testDate" nodeset="instance('test')/date" type="date"/> <xf:instance id="test"> <data> <date/> </data> </xf:instance> </xf:model> </head> <body> <div> <h1>Date Widget Test</h1> <xf:input bind="testDate"> <xf:label>Test Date</xf:label> </xf:input> </div> </body> </html> |
From: Alain C. <ala...@ag...> - 2011-06-10 12:40:05
|
Hello Philip, Yes, you're right! I found it myself yesterday. It was quite obvious with a Javascript debugger, finding where to set a breakpoint being the most difficult part ;-) Thanks! -Alain Le 10/06/2011 14:35, Philip Fennell a écrit : > > I believe I have the answer to this strange problem. > > In the Calendar() function, at line 5575 of xsltforms.js, the month is > set with: > > date.setMonth(cal.selectMonth.value); > > however, the setMonth method of the Date object can accept to > parameters: monthValue and dayValue. When dayValue is missing the date > value from getDate is used. When the current date's month value is > greater that the largest day value for the target month the setMonth > method will attempt to correct the month accordingly. Therefore, in my > test case of setting a target date of February 21^st on the date of > May 31^st , the getDate method will return 31^st which is outside of > the range for February (max 29^th ) and so it adds the difference and > rolls the month over into March. This behaviour is documented in the > JavaScript Reference: > > '/If a parameter you specify is outside of the expected range, > setMonth attempts to update the date information in the Date object > accordingly. For example, if you use 15 for monthValue, the year will > be incremented by 1 (year + 1), and 3 will be used for month./' > > The way I have solved the problem is to change line 5575 to this: > > date.setMonth(cal.selectMonth.value, cal.day); > > Regards > > Philip Fennell > Consultant > MarkLogic Corporation > > Phone +44 (0) 203 402 3619 | Mobile +44 (0) 7824 830 866 > > ema...@ma... > <mailto:Fir...@ma...> > webwww.marklogic.com <http://www.marklogic.com/> > > This e-mail and any accompanying attachments are confidential. The > information is intended solely for the use of the individual to whom > it is addressed. Any review, disclosure, copying, distribution, or use > of this e-mail communication by others is strictly prohibited. If you > are not the intended recipient, please notify us immediately by > returning this message to the sender and delete all copies. Thank you > for your cooperation > > *From:*Philip Fennell [mailto:Phi...@ma...] > *Sent:* Wednesday, June 08, 2011 1:47 PM > *To:* support xsltforms > *Subject:* [Xsltforms-support] A curious problem with the date picker > - odd months! > > Hello, > > There appears to be a very curious bug with the date picker that only > shows itself under certain circumstances. Here is how to recreate it: > > 1) Ensure the date of your computer is set to a calendar month that > has an odd number e.g. May (yes really!). I used the date 31/05/2011. > > 2) Open a form (see below for included test case) and using the date > picker widget set the date to 21^st of February (21/02/2011) in the > 'Test Date' control. > > Notice that the month in the date field is set to March 21/03/2011 and > not 21/02/2011 as selected. > > Now to prove that this is related to the machine's calendar month, go > and change the month back to June (an even month), do things like > clear the browsers cache and repeat the test. You will see that the > month does change this time. > > I have found this with the 494 release (because I'm using eXSLTForms > and its Rich Text Editor widgets) in Firefox 3.6.10 on Windows 7 and > it is still happening with the 503 release. > > Regards > > Philip Fennell > Consultant > MarkLogic Corporation > > Phone +44 (0) 203 402 3619 | Mobile +44 (0) 7824 830 866 > > ema...@ma... > <mailto:Fir...@ma...> > webwww.marklogic.com <http://www.marklogic.com/> > > This e-mail and any accompanying attachments are confidential. The > information is intended solely for the use of the individual to whom > it is addressed. Any review, disclosure, copying, distribution, or use > of this e-mail communication by others is strictly prohibited. If you > are not the intended recipient, please notify us immediately by > returning this message to the sender and delete all copies. Thank you > for your cooperation. > > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet href="/resource/xsltforms/xsltforms.xsl" > type="text/xsl"?> > <html xml:lang="en" lang="en" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xf="http://www.w3.org/2002/xforms" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns="http://www.w3.org/1999/xhtml"> > <head> > <title>Date Widget Test</title> > <xf:model> > <xf:action ev:event="xforms-ready"> > <xf:setvalue ref="instance('test')/date" > value="substring-before(now(), 'T')"/> > </xf:action> > > <xf:bind id="testDate" nodeset="instance('test')/date" type="date"/> > > <xf:instance id="test"> > <data> > <date/> > </data> > </xf:instance> > </xf:model> > </head> > <body> > <div> > <h1>Date Widget Test</h1> > > <xf:input bind="testDate"> > <xf:label>Test Date</xf:label> > </xf:input> > </div> > </body> > </html> > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > > > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support |