Prev | Current Page 129 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

getTime(); // 215874900000 for the birthday
The DateTools Class
Unfortunately, haXe offers only two functions for manipulating the date and time of a Date object:
delta and format . Also, the function getMonthDays is available for simple day count calculations.
delta()
It is expected that any adjustments to a Date object require the use of a secondary Date object or custom
functions to aid in performing date and time calculations. This function, delta , forms part of a new class
called DateTools and accepts the Date object you want to modify and the number of milliseconds, as a
Float value, that you wish to add to the date. For example, if you realized from the birth notes that the
actual time was actually 13:20 in the afternoon, you could add five minutes to the date by doing the
following:
birthDate = DateTools.delta(birthDate, 300000.0);
If, however, the time was actually 13:10 in the afternoon, then you could remove those five minutes by
supplying a negative value.
When dealing with larger dates, it is advisable to create your own functions for working out the number
of seconds in a month, day, hour, and so on.


Pages:
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141