I am using a wrapper of a C++ api which isn't really documented. Some of the exposed methods require fields (from and to) which are of type uint. The fields are actually datefrom and dateto, but the types aren't as such. I have tried different approaches, including converting datetime to DOS unsigned int representation
public ushort ToDosDateTime( DateTime dateTime)
{
uint day = (uint)dateTime.Day; // Between 1 and 31
uint month = (uint)dateTime.Month; // Between 1 and 12
uint years = (uint)(dateTime.Year - 1980); // From 1980
if (years > 127)
throw new ArgumentOutOfRangeException("Cannot represent the year.");
uint dosDateTime = 0;
dosDateTime |= day << (16 - 16);
dosDateTime |= month << (21 - 16);
dosDateTime |= years << (25 - 16);
return unchecked((ushort)dosDateTime);
}
, but still the api function call returned nothing if not an error. , I also tried the plain representation as : 20160101 which made sense but didn't succeed. Is there a known way of representing dates and times as unsigned integers?