Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Time conversion between MF and Full .Net


  • Please log in to reply
8 replies to this topic

#1 Saturnim

Saturnim

    Member

  • Members
  • PipPip
  • 12 posts

Posted 15 May 2011 - 03:01 PM

I have a problem with Time conversion between platforms. I get a Ticks filed from object created in full .Net and then I create new DateTime object in MF using this value. In new object is completely diffrent date and time. Can somebody tell me how to solve this problem?

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 15 May 2011 - 03:32 PM

Could you be more specific? Report an example, please.
Biggest fault of Netduino? It runs by electricity.

#3 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 15 May 2011 - 04:17 PM

Not having researched this, the time taken from the ticks is usually an offset from a base time. I'd be looking to create a time on both platforms with zero ticks. This will be the reference time. Display this time on both platforms - are they different? Regards, Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#4 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 15 May 2011 - 05:05 PM

In new object is completely diffrent date and time. Can somebody tell me how to solve this problem?

Is it really completely different or has just invalid year? In .NET Micro Framework the time origin is 1/1/1601 (vs. 1/1/1 in the 'full' .NET Framework), so you'd need to adjust it:

DateTime microDateTime = new DateTime(ticksFromFullFramework - 504911232000000000L);


#5 Michel Trahan

Michel Trahan

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts

Posted 15 May 2011 - 05:42 PM

Are the 2 ticks per second the same ? I think not ... just a thought !
Started with C in 1985, moved to Vb3 ... to vb6 and stopped. Now started with .Net and learning C# and VB.net and wishing VB.net was on MF !

#6 Saturnim

Saturnim

    Member

  • Members
  • PipPip
  • 12 posts

Posted 15 May 2011 - 06:21 PM

Is it really completely different or has just invalid year? In .NET Micro Framework the time origin is 1/1/1601 (vs. 1/1/1 in the 'full' .NET Framework), so you'd need to adjust it:

DateTime microDateTime = new DateTime(ticksFromFullFramework - 504911232000000000L);

This solved my problem! Thank you! And others for Interest.

#7 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 15 May 2011 - 06:50 PM

This solved my problem!

It seems the documentation is incorrect, I have filled an issue on CodePlex.

#8 Saturnim

Saturnim

    Member

  • Members
  • PipPip
  • 12 posts

Posted 15 May 2011 - 07:57 PM

It seems the documentation is incorrect, I have filled an issue on CodePlex.

I read the documentation... is incorrect

#9 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 16 May 2011 - 03:35 AM

It seems to me that most of the official documentation is a "copy-and-paste" from the classes of the standard framework.
For example, here is the SerialPort overview, that has almost on relation with the actual MF implementation.
Cheers
Biggest fault of Netduino? It runs by electricity.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.