Workitem740 FromUnixTimestamp
WEM No-Code Development

Workitem 740

FromUnixTimestamp Error when more than 12 digits

FromUnixTimestamp function with input numeric UnixTimeStamp that has more than 12 digits crashes the runtime.

System.ArgumentOutOfRangeException :
Valid values are between -62135596800 and 253402300799, inclusive.
Parameter name: seconds
at System.DateTimeOffset.FromUnixTimeSeconds(Int64 seconds)
at ZoomBim.Wem.Expressions.StandardLibrary.FromUnixTimestamp.NumberToDateImpl.Evaluate(IScriptEvaluationContext context, Object[] parameters) in ZoomBim.Wem.Common\Expressions\Functions\StandardLibrary.FromUnixTimestamp.cs:line 52

This has to do with the limit of unixtimestamp, originally this was stored as 32 bit int. which will cause problems in 2038 (int overflow).

Safe 32 bit value

If the value is within the 32 bit range (before the 2038 limit) then this should correctly convert. This never was a problem.

For example, the value 1735689600 should map to 2025-01-01

 

 

Above 32 bit value

If the value is bigger than 2^32 (after 2038), then this was an issue. This should now work correctly.

For example, the value 2208988800 should map to 2040-01-01

 

 

After year 9999

The max value of a DateTime in .NET (and therefore in WEM) is 9999-12-31. So values that correspond to dates after this year will not be converted.

Note that expressions never throw, so in this case the result will be an empty value.

The value 3155361696000 maps to a such a date.

 

Node ID: 18516071