Sending DateTime to other platforms question.

G

Guest

Hi,

I'm writing a server applicaiton using C# and .NET Framework.
This server sends out time to all the clients. The clients are expected to
be
written in various platforms for example, Delphi, VB 6.0, C/C++, Java etc.

How I can send the DateTime from .NET Framework to all these other platforms.
I heard that sending time in "double" format would be accepted by all the
platforms.

Can we convert DateTime in C# to Double at all?
If we use DateTime.ToFileTime() which return an Int64, can other platforms
covert this Int64 back to the time?

Kindly let me know.

Cheers,

Naveen.
 
B

Brendan Green

What about sending it as a string, formatted as YYYY-MM-DD HH:MM for
example?

That way, you can perform conversions specific to each platform and away you
go?
 
T

TT \(Tom Tempelaere\)

Hi Naveen,

Naveen Mukkelli said:
Hi,

I'm writing a server applicaiton using C# and .NET Framework.
This server sends out time to all the clients. The clients are expected to
be
written in various platforms for example, Delphi, VB 6.0, C/C++, Java etc.

How I can send the DateTime from .NET Framework to all these other
platforms.
I heard that sending time in "double" format would be accepted by all the
platforms.

Can we convert DateTime in C# to Double at all?
If we use DateTime.ToFileTime() which return an Int64, can other
platforms
covert this Int64 back to the time?

Kindly let me know.

Cheers,
Naveen.

You could choose XML as the interchange data format, and use the xs:dateTime
data type. The internet has a lot of useful pages to help you out for using
Xml, this one is probably good too http://www.w3.org/XML/Schema. The .NET
Framework has a namespace with a lot of classes to work with Xml,
System.Xml.

Hope this helps,
Tom T.
 
S

Scott Maskiel

Hi Naveen,

Personally I'd follow the other's suggestions of using strings or
xsd:datetime formats, but if your heart is set on a numeric datatype
then you can use DateTime.ToOADate to convert to a Double, or you can
use the DateTime.Ticks property to return an Int64 that you can write
conversion routines for from within your other platform routines.

I can't speak for other platforms but the double valuer returned by
ToOADate translates directly into a TDateTime datatype on the Delphi
side.

I have developed Delphi code to convert a .NET DateTime.Ticks property
value to a TDateTime if you're interested.

Regards,
Scott
 
G

Guest

Hi guys,

Thanks for taking time to posting replies.

What happens if we just send DateTime from .NET(C#).
Would the other platforms be able to pick up the correct time from .NET
DateTime.

Cheers,

Naveen.
 
T

TT \(Tom Tempelaere\)

Naveen,

Naveen Mukkelli said:
Hi guys,

Thanks for taking time to posting replies.

What happens if we just send DateTime from .NET(C#).
Would the other platforms be able to pick up the correct time from .NET
DateTime.

Cheers,
Naveen.

I don't see any way of doing that, since each platform or framework has its
own representation of a DateTime data type. I think on the binary level that
there is little or no compatibility with other platforms.

Hence you choose a platform independent representation, and the best choice
now is XML. The XML Schema Definition Standard (XSD) defines types as
xs:dateTime or xs:time and the like. Nowadays I think every platform
supports XML so I think the choice is easy.

Unless of course you define your own (binary) serialization, and have a
framework on each platform that can convert it to the platform's natural
date-time structure.

Hope this helps,
Tom T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top