364,033 Members | 4781 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Sending DateTime to other platforms question.

Naveen Mukkelli
P: n/a
Naveen Mukkelli
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.

Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


Brendan Green
P: n/a
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?

"Naveen Mukkelli" <NaveenMukkelli@discussions.microsoft.com> wrote in
message news:07FE89EC-8CF3-47BC-BEC5-B908B0A10712@microsoft.com...[color=blue]
> 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.
>[/color]


Nov 17 '05 #2

TT \(Tom Tempelaere\)
P: n/a
TT \(Tom Tempelaere\)
Hi Naveen,

"Naveen Mukkelli" <NaveenMukkelli@discussions.microsoft.com> schreef in
bericht news:07FE89EC-8CF3-47BC-BEC5-B908B0A10712@microsoft.com...[color=blue]
> 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.[/color]

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.


Nov 17 '05 #3

Scott Maskiel
P: n/a
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

On Tue, 10 May 2005 19:06:01 -0700, Naveen Mukkelli
<NaveenMukkelli@discussions.microsoft.com> wrote:
[color=blue]
>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.
>[/color]

Nov 17 '05 #4

Naveen Mukkelli
P: n/a
Naveen Mukkelli
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.



"Scott Maskiel" wrote:
[color=blue]
> 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
>
> On Tue, 10 May 2005 19:06:01 -0700, Naveen Mukkelli
> <NaveenMukkelli@discussions.microsoft.com> wrote:
>[color=green]
> >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.
> >[/color]
>
>[/color]
Nov 17 '05 #5

TT \(Tom Tempelaere\)
P: n/a
TT \(Tom Tempelaere\)
Naveen,

"Naveen Mukkelli" <NaveenMukkelli@discussions.microsoft.com> schreef in
bericht news:9E5F5341-66AC-46AE-8956-D60573401267@microsoft.com...[color=blue]
> 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.[/color]

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.


Nov 17 '05 #6

Post your reply

Help answer this question



Didn't find the answer to your C# / C Sharp question?

You can also browse similar questions: C# / C Sharp