Now that the whole ECMAScript thing has blown over, Adobe is free of being
quite so bound to it as a standard.  They've expressed interest in doing
some things that they previously shied away from because of divergence from
the standard.

Is anyone else really interested in ditching the Date class?  That thing
drives me nuts.  The number one problem is that it's an object.  So you get
something like this:

var myDate:Date = new Date(2008, 1, 1);
var myDate2:Date = myDate;
...
myDate2.month++;

It's an easy mistake to miss, especially for beginners, and it can be very
annoying to track done.  It's also a pain that you can assign values to the
time, day, month, etc. properties and it screws up data bindings and
setters/getters.  For example, if I have:

private var myDate:Date;
[Bindable] public function set myDate(value:Date):void
{
  _myDate = value;
  invalidateDisplayList();
}
public function get myDate():Date
{
  return _myDate;
}

It works great until you do something like:
  myDate.time = newDate.time;
or
  myDate.date++;


Simliar difficulties exist when using a date dropdown control.

So is it time to get a new Date class?  Perhaps a new one called DateTime
and make the old one deprecated.

What I'd love is for it to be a new primitive type (like Number, int,
Boolean) that would be stored the same way as the time property of Date and
would be manipulated through static functions of the DateTime class.
Examples:

var myDate:DateTime = DateTime.now();
trace("myDate:", myDate);
>> myDate: 1228248636245

myDate = DateTime.incHour(myDate);
myDate = DateTime.incMinute(myDate, 20);
myDate = DateTime.incMonth(myDate, -3);
myDate = DateTime.incHourUTC(myDate);
myDate = DateTime.encode(2008, 1, 1);
var hours:Number = DateTime.getHours(myDate2 - myDate1);

No more "date" or "fullYear" - use the much more intuitive "day" and
"year".  I would also like month to be one-based, but that'd probably make
enough people grumble that I'd be willing to live without it.

I dream of seeing all the existing controls and such that use Date updated
to use this code instead.  I would have already created the DateTime class
if it wasn't for how much trouble daylight savings time, leap year and
internationalization would be.

-- 
Jason

Reply via email to