Issue on Sugar.DateTime

I’ve created a simply cross-platform static library by C# element on VS.NET 2015 RC version, the library build successfully and return three different types of static library(.a, .jar and .dll) on corresponding project folders.

I tried to import the .a & .h library into my Xcode Swift 1.2 project ,.jar into my Android studio project and .dll into my VS.Net 2015 project.

It is working fine on VS.Net 2015 project, but I got an error on Xcode and Android Studio projects due to the DateTime datatype cannot be reconciled, I think the problem is Java is using “Date” and Xcode is using “NSDate” as the data type

Below is my testing function using c# element VS 2015 RC version

public Sugar.DateTime returnDateTime() {
    Sugar.DateTime dummy = Sugar.DateTime.Now;
    
    return dummy;
}

Below is the open souroce for Sugar on GitHub, I guess the problem may be related to the following code doesn’t handle the mapping datetime for different platform. please help, thanks.

DateTime = public {$IF COOPER}record{$ELSEIF ECHOES}record mapped to System.DateTime{$ELSEIF NOUGAT}class{$ENDIF}

Just to be clear, what error do you get and where do you get it?

DateTimeTesting.zip (22.4 KB)

Attached is my testing program.

I got the following error message on Xcode when including the static library, the static library is generated by RemObjects C# under VS.NET 2015.

"error: unknown type name ‘DateTime’

Or you may find the library from my testing project under the following path:
…/DateTimeTesting\bin\Debug\iOS\libDateTimeTesting.a
…/DateTimeTesting\bin\Debug\iOS\DateTimeTesting.h

Thanks, logged as bugs://72264

May I know your timeline for the next release? thanks. :grinning:

Hello,

Could you please give me more info on that error. I tried to reproduce it for Android Studio and couldn’t. With referenced .jar I’m able to call the returnDateTime method and the project compiles fine. Though I added reference to sugar to be able to assign the result of method to any var.
Did you added the reference to sugar also (sugar.jar for Android).

Best regards.

Which method I need to use for my Android Studio project in order to get the result from returnDateTime function?

Method 1
Sugar.DateTime a = returnDateTime ();

or

Method 2
Date a = returnDateTime ();

Currently I’m using method 2 in my JAVA project.

Hello,

we have added the changes into sugar. Now the DateTime type is mapped to java.util.Calendar for java and NSDate for nougat.

Best regards.

bugs://72264 got closed with status fixed.