IsDateValid returning strange response

Hi,

I'm having an issue with the IsDateValid function. I created a custom date field called expire_date, and put a date in the future when the license should expire. When I run my function, it does what it is supposed to, in that it returns 0 when the expiration date is in the future, and 1 when the date is already passed. However, when the date is valid, calling print_ta_error does not return TA_OK according to the values given in the documentation, but rather it returns "Unknown". Grateful if you could take a look at the code and see if the problem is on my end - I don't want to risk there being some issue that might cause problems later on.

hr = GetFeatureValue(_T("expire_date"), 0, 0); TCHAR * featureValue; featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR)); hr = GetFeatureValue(_T("expire_date"), featureValue, hr);

if (hr == TA_OK) { if (strcmp(featureValue, "1970-01-01 00:00:00") == 0) { //this special date means the license is permanent, so ignore expiry date printf("Permanent License is installed. "); } else { printf("License Expiry Date: %s\n", featureValue); char s[21]; size_t i; struct tm tim; time_t now; now = time(NULL); tim = *(localtime(&now)); i = strftime(s,21,"%Y-%m-%d %H:%M:%S\n",&tim); printf("Current Date: %s\n", s); hr = IsDateValid(_T(featureValue), TA_HAS_NOT_EXPIRED); print_ta_error(hr, "Date check result: "); }

} else printf("Getting feature failed: %d\n", hr);

free(featureValue); }

What version of TurboActivate are you using? What's the return code for IsDateValid? Are you messing around with your system clock? If so, note that IsDateValid() detects a lot of that and just say "nah, the dates not valid because the clock has been messed with".

That's the strange thing - running the print_ta_error function should give me "Date Check result: TA_OK:0" but instead I'm getting "Date Check result: (Unknown:0)" when the date is not expired and "Date Check result: (Unknown:1)" when the date is expired. So I am getting the correct code numbers, but not the TA's which makes me feel something is wrong somewhere.

To the best of my recollection, this was happening before I started playing with the computer's dates, but seeing as I had to be monkey-ing around to get the code running in the first place I cannot be sure of that. However, I would think that if the system date was suspect it would return "1" all the time? What's the procedure for returning things to a pure state so I can check and see if that's what's messing things up?

And I'm using the Linux version on an ARM processor.

Sorry - need to correct something - when it the date is not expired, I get "Date check result: (Unknown: 0)" and when it is expired I do get (TA_FAIL).

0 is a success. 0 is TA_OK. 1 is a failure., 1 is TA_FAIL. It sounds like everything is working correctly. I don't know why your "print_ta_error " isn't working. We didn't write that. All you need is a simple if statement:

if (IsDateValid(featureValue, TA_HAS_NOT_EXPIRED) == TA_OK){    // date is valid}else{    // date has expired.}

Apologies - thought print_ta_error was one of the functions from your sample code, but it seems another developer had added that in-house.