When I run the following code. The date I get back on the .net side is 12/20/0001 instead of 1/1/0002. Can anybody explain to me why? Is there something I'm missing here? (I apologize if the code has some syntax errors, it was copy and pasted and then deleted the unimportant stuff to simplify the question.
/* C# code */
public void getdate(out DateTime dteMyDate)
OpenAppObject openAO = OAFactory.GetOpenAppObject();
dteMyDate= new DateTime(1900,1,1);
Progress.Open4GL.Proxy.ParamArray objSet = new Progress.Open4GL.Proxy.ParamArray(1);
objSet.AddDate(0, null, Progress.Open4GL.Proxy.ParamArrayMode.OUTPUT);
dteWorkDate = (DateTime)objSet.GetOutputParameter(0);
/* Openedge Code */
define output parameter dteMyDate.
dteMyDate = 1/1/0002.
On October 4, 1582 there is an anomaly in the Gregorian calendar because 10 days were dropped. The next day was October 15, 1582. This may account for your problem. I do not understand your code so I am not sure.
Is progress adding an integer number of days to a base date during the conversation to a .net date? If so what is the base date it is using and how can we determine the offset. The response makes sense since when i was playing around 1/1/1600 worked fine but 1/1/1500 did not. If I just create a new .net datetime (new DateTime(1,1,1)) everything is fine, so I'm assuming there is some calendar arithmetic going on there.
I do not know how the conversion you are using is done. But in the 4GL, you can convert from the Windows calendar to the 4GL calendar easily. The Windows clock starts at midnight, jan 1, 1601. Time is measured in centinanosecond intervals (i.e. 100 nanosecond "ticks"). The code to convert windows time to a 4GL datetime goes like this:
function winTime2DateTime returns datetime (input wt as int64):
/* Convert Windows time in 100 nanosecond ticks to 4GL DATETIME */
wt = (wt - 5000) / 10000.
return add-interval (datetime (1, 1, 1601, 0, 0, 0, 0), wt, "milliseconds").