| Page 1 of 1 | [ 10 posts ] |
|
Hi,
I was looking at your library for Date parsing and thought I found what I was looking for - that is, a javascript library that is able to parse dates in Australian format properly. On this page - http://developer.yahoo.com/yui/3/exampl ... parse.html when I enter the Date 31/07/2011 into the textbox and hit the Parse date button, the following date comes out the other end: Sun Jul 07 2013 00:00:00 GMT+0930 (AUS Central Standard Time) Not 31 July 2011. It would be good if you could include the smarts to parse a string such as 31/07/2011 and control the culture (perhaps by passing in some kind of Culture object as an overloaded parameter. Parsing strings into dates in javascript is always a headache, unless toy are using a commercial library such as Telerik, which has the smarts to do this. That is all. Looks like a nice library otherwise. |
|
Did you take a look at the Date.format method?
http://developer.yahoo.com/yui/3/exampl ... ormat.html |
|
I have not looked at it.
But I am guessing it is for formatting a date to string, rather than parsing a string to a date. |
Alberto SantiniYUI Contributor
|
Hello David.
There is a series about Date formatting with YUI (2): http://www.yuiblog.com/blog/2009/02/11/ ... ing-pt1-2/ http://www.yuiblog.com/blog/2009/02/25/ ... tting-pt2/ http://www.yuiblog.com/blog/2009/03/18/ ... tting-pt3/ http://www.yuiblog.com/blog/2009/07/06/ ... tting-pt4/ I think the articles don't answer directly to your needs, but the main question is the following one: how did you create the string "31/07/2011"? In terms of Date object, that string has not a precise meaning and you cannot parse correctly: indeed you cannot pass it tout court as argument to the Date constructor. The string "Sun Jul 07 2013 00:00:00 GMT+0930" is a well-formed Date string in terms of strftime standard [1]. My point is the following one: if we need to convert a string to a Date, firstly we should be sure to serialize correctly the Date object (from a database field, from a form, etc.). My two cents, IceBox [1] http://pubs.opengroup.org/onlinepubs/00 ... ftime.html |
|
Hi Alberto,
There are quite a few ways for a date to be input by a user as 31/07/2011 (remember, that's Ausn format, not US. We're sensible in our ordering of date values - day/month/year On a crude interface, it may just be a textbox where a user has typed in the string 31/07/2011. The reason I have so much time for the Telerik controls is because they have client-side API's. So, so long as the user inputs a valid date format, the getDate() call will parse that string into a javascript date object. It doesn't care about the 00:00:00 GMT+0930 part of the date. And in many cases, neither does the user themselves. So, my wishlist for a Date parsing api would be one that can achieve what Telerik's control does (via its client-side API). I'm sure other 3rd party component vendors may have solved this problem as well. But I have not seen it yet in any open source js libraries. As I set out in my original post, YUI - fail. So, hopefully they'll improve it with the next release. It is a very difficult problem to solve. But that's life for a language that does not have strong types. |
|
Quote: 31/07/2011 (remember, that's Ausn format, not US It doesn't have anything to do with US format. The problem is that DD/MM/YYYY is not a valid IETF-compliant RFC 1123 date string. Just as you could not pass a string in that format to the native JavaScript Date constructor, nor can you pass it to the YUI DataType.Date.Parse method and expect it to work. This is not a fail on YUI's part, though I think it would be a good feature request to be able to pass in a format parameter. Another option would be to better control how users input the date. In other words, avoid using a single text box (as that could be problematic in many ways). |
Alberto SantiniYUI Contributor
|
Hello David.
If you need an input form library based on YUI2 you may give a look at inputEx [1][2]. Hope that helps, IceBox [1] http://neyric.github.com/inputex/ [2] http://neyric.github.com/inputex/exampl ... field.html P.S. I don't know if Form Module (YUI3) in Gallery can accomplish to your needs. http://yuilibrary.com/gallery/show/form |
|
IceBox,
The examples on the first page in the series on Date formatting with YUI2 don't work. http://www.yuiblog.com/blog/2009/02/11/ ... ing-pt1-2/ I get the following in the error console (in Firefox 3.6.13): Quote: Error: YAHOO.util.Date is undefined Source File: http://yuiblog.com/assets/dateformatting/part1.js Line: 33 Error: YAHOO.util.Date is undefined Source File: http://www.yuiblog.com/blog/2009/02/11/ ... ing-pt1-2/ Line: 1 Same in IE7: Quote: Message: 'document.getElementById(...)' is null or not an object Line: 33 Char: 1 Code: 0 URI: http://yuiblog.com/assets/dateformatting/part1.js Message: 'YAHOO.util.Date' is null or not an object Line: 170 Char: 1 Code: 0 URI: http://www.yuiblog.com/blog/2009/02/11/ ... ing-pt1-2/ The examples are still useful though If someone takes the time to fix the page, perhaps they can also add a link on each part to the next part of the series. For example, a link on Part 1 to Part 2 would be useful, as would a link on 2 to 3 and 3 to 4. The articles link backwards but not forwards, and now that they're all published it should be easy to do. Thanks, Paul |
Alberto SantiniYUI Contributor
|
Hello Paul.
I think they work with 2.6.0 and now they are outdated. I don't control YUI blog pages. Anyway thanks for your feedback. Regards, Alberto |
|
I'm using the YAHOO.date.Util classes in 2.8 and they work fine.
Thanks again, Paul |
| Page 1 of 1 | [ 10 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group