Re: DateField Issues and fixes

2013-04-21 Thread Andriy Panas
Hi Justin,

FYI, few years ago, I did a closer examination of existing limitations of
current DateFormatter from Flex3 and suggested a few fixes for the
following issues (old JIRA numeration):

Fixed SDK-23069  https://bugs.adobe.com/jira/browse/SDK-23069[Localization]:
DateFormatter.parseDateString does not support non-latin characters in
month and days names;

Fixed SDK-23075 https://bugs.adobe.com/jira/browse/SDK-23075 “[Localization]:
DateField should support “MMM” and “” for formatString”;

Fixed SDK-26715 https://bugs.adobe.com/jira/browse/SDK-26715 “DateFormatter
“parseDateString” method cannot parse dateString value formatted with non
default en_US format”;

Demo:
http://jabbypanda.com/blog/2010/12/datefield4-component-for-flex-4-sdk/

If you are interested in code, it is available at the Github

https://github.com/JabbyPanda/DateField4



On 20 April 2013 08:57, Alex Harui aha...@adobe.com wrote:




 On 4/19/13 5:28 PM, Justin Mclean jus...@classsoftware.com wrote:

 
  Alex if you could review the tests as I'm not 100% familiar with
 Mustella I'd
  appreciate it.
 
 Looks like the right pattern for testing methods.  Good job!

 --
 Alex Harui
 Flex SDK Team
 Adobe Systems, Inc.
 http://blogs.adobe.com/aharui




Re: DateField Issues and fixes

2013-04-21 Thread Justin Mclean
Hi,

Thanks for that I take a look tomorrow.

I have to ask did you write all the code yourself and are able to donate it to 
Apache Flex? From what I can see it's under a Apache style licence already.
https://github.com/JabbyPanda/DateField4/blob/master/LICENSE

Thanks,
Justin

Re: DateField Issues and fixes

2013-04-20 Thread Alex Harui



On 4/19/13 5:28 PM, Justin Mclean jus...@classsoftware.com wrote:

 
 Alex if you could review the tests as I'm not 100% familiar with Mustella I'd
 appreciate it.
 
Looks like the right pattern for testing methods.  Good job!

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui



Re: DateField Issues and fixes

2013-04-19 Thread Justin Mclean
Hi,

 Thanks.  Do you have time to add some more tests?
Added 40 odd tests to check various formats and check invalid inputs.

https://git-wip-us.apache.org/repos/asf?p=flex-sdk.git;a=commitdiff;h=531f7f2fe7aa72fa3c998d76c2de7b9b1761ee03

All test pass.

If anyone can suggest other tests go ahead and I'll add them.

Alex if you could review the tests as I'm not 100% familiar with Mustella I'd 
appreciate it.

Thanks,
Justin

Re: DateField Issues and fixes

2013-04-18 Thread Alex Harui
Thanks.  Do you have time to add some more tests?


On 4/18/13 8:42 PM, Justin Mclean jus...@classsoftware.com wrote:

 Hi,
 
 I've been looking at DataField and it has a few problems mostly how it dealing
 with format string parsing in stringToDate and dateToString static methods.
 
 There are several unresolved JIRA issues around this component.
 
 Some of the issues include.
 
 1. Poor support of M and D vs MM and DD. Currently:
 1/10/2013 formatted with D/M/YY = null
 1/10/2013 formatted with D/MM/YY = null
 1/10/2013 formatted with M/D/YY = null
 7/17/69 formatted with M/D/YY = null
 1/30/13 formatted with M/D/YY = null
 
 And also this - which is just plain wrong! It should either reject the format
 as being invalid or be able to deal with it.
 
 Tue Oct 1 00:00:00 GMT+1000 2013 formatted with D/M/YY = 1/1013
 Thu Jul 17 00:00:00 GMT+1000 1969 formatted with M/D/YY = 7/1769
 Thu Jul 17 00:00:00 GMT+1000 1969 formatted with D/M/YY = 177/69
 Tue Oct 1 00:00:00 GMT+1000 2013 formatted with M/D = 1001
 
 2. Invalid formatting of invalid dates
 Invalid Date formatted with DD/MM/ = NaN/NaN/NaN
 
 3. Magic cut off in 1970.
 7/17/71 formatted with MM/DD/ = Sat Jul 17 00:00:00 GMT+1000 1971
 7/17/69 formatted with MM/DD/ = Wed Jul 17 00:00:00 GMT+1100 2069
 
 I've  rewritten the methods in a cleaner way that support a wider range of
 formats and fixes all the issue above.
 
 The code is in the style of the existing SDK code (which is a little ugly
 IMO). Any feedback,potential bug etc etc would be appreciated.
 
 There a bit more work to do with stringToDate and support for formats without
 separators - which might be tricky.
 
 The mustella DateField tests all pass however I believe it only tests the US
 centric MM/DD/ format.
 
  [java] =
  [java] Passes: 327
  [java] Fails: 0
  [java] =
 
 Thanks
 Justin
 
 
 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui



Re: DateField Issues and fixes

2013-04-18 Thread Justin Mclean
Hi,

 Thanks.  Do you have time to add some more tests?
Mastella test no as I'm not 100% familiar with them yet. 

I tested locally with about 50 combinations of formats and dates. I run against 
4.9 and 4.10 and diffed the trace output to see what had changed.

Here the rough test code I used - it could be better but covers more ground 
that the existing tests :-) 

When I get some time I'll see if I can convert it into something mustella 
friendly.

?xml version=1.0 encoding=utf-8?
s:Application xmlns:fx=http://ns.adobe.com/mxml/2009; 
   xmlns:s=library://ns.adobe.com/flex/spark 
   xmlns:mx=library://ns.adobe.com/flex/mx 
initialize=init()

fx:Script
![CDATA[
import mx.controls.DateField;

public function testStringToDate(date:String, 
format:String):void
{
var result:Date;

try {
result = DateField.stringToDate(date, 
format);
}
catch (error:Error) {
trace(OPPS RTE!  + error.message);
}

if (result != null) {
trace(date +  formatted with  + 
format +  =  + result.toString());
}
else {
trace(date +  formatted with  + 
format +  = null);
}   
}

public function testDateToString(date:Date, 
format:String):void
{
var result:String;

try {
result = DateField.dateToString(date, 
format);
}
catch (error:Error) {
trace(OPPS RTE!  + error.message);
}

if (result != null) {
trace(date +  formatted with  + 
format +  =  + result);
}
else {
trace(date +  formatted with  + 
format +  = null);
}   
}


protected function init():void
{
var result:Date;

// MM/DD/
testStringToDate(01 01 2013, MM/DD/);
testStringToDate(01/01/2013, MM/DD/);
testStringToDate(1/1/2013, MM/DD/);
testStringToDate(1/10/2013, MM/DD/);
testStringToDate(1/10/2013, MM/DD/);
testStringToDate(30/1/2013, MM/DD/);
testStringToDate(7/17/69, MM/DD/);
testStringToDate(30/1/13, MM/DD/);  
testStringToDate(2013/1/1, /M/DD)
testStringToDate(13 6 2013, DD MMM )

testStringToDate(1/10, MM/DD/);
testStringToDate(2013, MM/DD/);
testStringToDate(1/1/10/2013, MM/DD/);
testStringToDate(13/10/2013, MM/DD/);
testStringToDate(1/45/2013, MM/DD/);

testStringToDate(1-10-2013, MM/DD/);
testStringToDate(1 10 2013, MM/DD/);
testStringToDate(1/10-2013, MM/DD/);
testStringToDate(1///10-2013, MM/DD/);
testStringToDate(1/10/2013/, MM/DD/);
testStringToDate(/1/10/2013, MM/DD/);
testStringToDate(110//2013, MM/DD/);
testStringToDate(110  2013, MM/DD/);

// DD/MM/
testStringToDate(01/01/2013, DD/MM/);
testStringToDate(1/1/2013, DD/MM/);
testStringToDate(1/10/2013,