ActiveCompanionSet xtras for Macromedia DirectorDate/Time Data Wrapper
Date/Time wrapper is provided by VbScriptXtra for handling date/time data. It is created automatically by typecasting routines when VB date/time value is detected. This wrapper provides standard for VB functionality for formatting date/time values and other features.
Date/time data wrapper is free. You may download ActiveCompanionSet and use the Date/Time wrapper. Read the License agreement for more details.
To explicitly create this wrapper use xtra-level CreateWrapper method:
dateWrapper = xtra("VbScriptXtra").CreateWrapper( #Date )
Newly created date/time wrapper is initialized with the current system time.
Use Interface() method to get the short description of methods and properties provided by this object.
put dateWrapper.Interface()
Use FormatDate and FormatTime methods to get date and time portions of the wrapped value in text representation formatted according the specified format.
put dateWrapper.FormatDate("MMM''''dd")
-- "Aug'31"
put dateWrapper.FormatTime("HH':'mm''''ss")
-- "22:01'51"
Properties provided by this object allows working with date/time value in float representation and getting user friendly date/time value parts as year, month, day, etc.
Also the wrapper provides conversion date/time value from local user's time zone to universal time and vice versa.
Internally the Date/Time wrapper stores float number. The whole part is the number of days since December 30, 1899. The fractional part represents the time of day.
The value 2.0 represents January 1, 1900;
3.0 represents January 2, 1900, and so on.
2.5 represents noon on January 1, 1900;
3.25 represents 6:00 A.M. on January 2, 1900, and so on.
Negative numbers represent the dates prior to December 30, 1899.
Samples
Use the Value property to access wrapped floating value. Setting this property allows doing some date/time calculations:
dateWrapper = xtra("VbScriptXtra").CreateWrapper( #Date )
put dateWrapper
--"< VbScriptXtra, Date/Time, 21.04.2006 19:50:34 >"
put dateWrapper.Value
-- 38828.8268
put dateWrapper.FormatDate("MM.dd.yyyy")
-- "04.21.2006"
dateWrapper2 = xtra("VbScriptXtra").CreateWrapper( #Date )
dateWrapper2.Value = dateWrapper.Value + 3
put dateWrapper2.FormatDate("MM.dd.yyyy")
-- "04.24.2006"
-- You may also use Lingo Date objects and arithmetics
dateWrapper2.Value = the systemdate + 60
put dateWrapper2.FormatDate("MM.dd.yyyy")
-- "06.20.2006"
-- Some non trivial arithmetic operations
dateWrapper2.Value = date(2006,4 + 12,21)
put dateWrapper2.FormatDate("MM.dd.yyyy")
-- "04.21.2007"
|