The Universal Time Scale api available in ICU has only three calls:
one call for get meta information about a different time scale unit (Java, .NET, DB2, Mac, Excel)
one call for converting to an external time scale unit
one call to convert from an external time scale unit.
The internal time scale unit for this API is .NET oriented, but with an extended range. as you can see in the example below: it is good, if the programmer is working with UTC oriented DateTimes.
An example. In C# we write
DateTime aDateTime = new DateTime (2013, 1, 1, 0, 0, 0); var tick = aDateTime.Ticks;
For this example you get the value “634925952000000000” and you transfer this binary value to VASmalltalk, where it is converted back to DateAndTime:
| dotNetTicks icuTicks anUError dateTime | anUError := UErrorCode new. " conversion from DOT-NET to the universal time scale in ICU - which is also DOT NET based - therefore you get the output equal to input. Be careful - this is meant to be UTC time ticks !!!!!! " dotNetTicks := ICUFunctions::UtmScaleFromInt64 callWith: 634925952000000000 with: ICUConstants::UDTS_DOTNET_DATE_TIME with: anUError. " now the conversion to ICU time " icuTicks := ICUFunctions::UtmScaleToInt64 callWith: dotNetTicks with: ICUConstants::UDTS_ICU4C_TIME with: anUError. DateAndTime fromICUTicks: icuTicks
And you get an instance of DateAndTime with the values (2013,1,1,1,0,0) with zone offset of +1.
The API allows conversions from/to: MacOSX, Unix, ICU, Java, Javascript, Extended Unix Time, Excel, DB2, Windows File Time, .NET
Leave a comment