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

ISO 8601 trim DateTime milliseconds

datetime azure ntp

  • Please log in to reply
3 replies to this topic

#1 Jeffa

Jeffa

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationCurrently Los Angeles

Posted 19 February 2013 - 06:09 PM

I'm attempting to create table data in Azure with mobile services. Got it working. It looks to me that my ndp2 is producing and persisting valid ISO 8601 DateTime to azure However the json.net JsonConvert.DeserializeObjectAsync in my Metro application barfs on the DataTime Deserialize. Please see this Stackoverflow quesion would appreicate it if you have experience with javascript and .net json.net.

 
While trying to debug it or otherwise get it to work I decided to
 
1) Change the DateTime.Now to DateTime.UtcNow 
      The DateTime retuned in Json from Azure still uses 'K' rather than what I thought would be 'Z':
            "2013-02-19T16:46:55.205K"
 
2) Trim the milliseconds off the DateTime before I persist. Apparently no Parse in the .netmf DateTime. Is there a way to tell DateTime to drop the milliseconds? 
 
I use Stephan's Toolbox.NETMF.NET.SNTP_Client and set the date from ntp. (some day I'd like to understand more about TimeZone in .netmf no SetTimeZone)
 
            // Initializes the time client            SNTP_Client TimeClient = new SNTP_Client(new IntegratedSocket("time-a.nist.gov", 123));            // ExtendedTimeZone.SetTimeZone(TimeZoneId.Arizona); // not supported            TimeClient.Synchronize();

 

The azure update. What might I use for DateTime.Parse as it is apparently unsupported? Or trim milliseconds from DateTime? 

 

        public static void AzureUpdateThread()        {            while (true)            {                string strTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");                DateTime dateTimeMinusMilliSeconds = DateTime.Parse(strTime); // Apparently no DateTime.Parse                HistoricalTemperatureDataForAzure htdForAzure = new HistoricalTemperatureDataForAzure()                {                    DataLoggerName = DataLoggerName,                    // Time = DateTime.Now,                    // Time = DateTime.UtcNow,                    Time = dateTimeMinusMilliSeconds,                    Temperature0 = temperature0,                    Temperature1 = 0                };                var json = MobileService.GetTable("HistoricalTemperatureData").Insert(htdForAzure);                Thread.Sleep(5 * 60 * 1000);            }

 

 

 
 
 

---
KF7CRU @jhalbrecht
Work: www.iea-software.com
Tmi: www.rodaw.com, tumblr.rodaw.com

#2 Jeffa

Jeffa

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationCurrently Los Angeles

Posted 19 February 2013 - 06:32 PM

Interesting. I put a couple Debug.Print in the code. Looks like the DateTime.UtcNow is not putting in milliseconds

....

Time = DateTime.UtcNow;

Debug.Print(Time);

 

 

02/19/2013 18:25:20 

---
KF7CRU @jhalbrecht
Work: www.iea-software.com
Tmi: www.rodaw.com, tumblr.rodaw.com

#3 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 19 February 2013 - 06:34 PM

thats normal, its the same for windows apps.



#4 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 19 February 2013 - 07:01 PM

Here are some references on DateTime ToString format patterns,

 

http://msdn.microsof...y/ee436729.aspx

http://msdn.microsof...imepattern.aspx

http://msdn.microsof...y/bb882581.aspx







Also tagged with one or more of these keywords: datetime, azure, ntp

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.