Keeping time
#1
Posted 05 March 2011 - 04:14 PM
#2
Posted 05 March 2011 - 05:07 PM
Off topic but the ZX81, probably the first cheap usable home computer is 30 years old today.Just guessing that the Netduino has as much processing power as the original PC ;-)
This had me thinking about how times have moved on looking at my hobbies then and now. At the time I had an amateur interest in electonics. This lasted about 4 years and then lapsed as I could not find the money to support the hobby and go through university at the same time. 30 years on and I now find myself playing with hardware once again.
Looking back to 1981 we had the ZX81
- Z80 based system based on the MK14 computer kit (worked on by Chris Curry)
- 64 KBytes RAM
- Video output to TV
- No real keyboard
- Programs written in BASIC, stored as byte codes and interpreted
- ARM based processor (ARM was born from Acorn Computers which in turn was founded by Chris Curry)
- 60 KBytes RAM
- No video output
- No keyboard at all
- Programmed in C#, stored as byte codes which are interpreted
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
#3
Posted 05 March 2011 - 06:00 PM
#4
Posted 15 February 2014 - 02:31 PM
OK, I give up.
I know its going to be really obvious to someone who does C# for their day job:
- How do I read the "local" time back after using SetLocalTime() ???
Paul - ever so slightly frustrated after spending an hour searching the forums and the web.
#5
Posted 15 February 2014 - 02:43 PM
OK found it.
Needed to take a deep breath and try a new search.
DateTime theTime = DateTime.Now;
or
DateTime theUtcTime = DateTime.UtcNow;
and if you want the date
DateTime theDate = DateTime.Today;
which returns the date and time, with the time part set to all zeros. Not sure if thats the local date or UTC date!
Too obvious for me to find.
#6
Posted 15 February 2014 - 03:04 PM
Simple test/demo program:
using System;using Microsoft.SPOT;namespace Clock_TestHarness{ public class Program { public static void DisplayTime() { // Read current times TimeSpan machineTimeNow = Microsoft.SPOT.Hardware.Utility.GetMachineTime(); DateTime localTimeNow = DateTime.Now; DateTime utcTimeNow = DateTime.UtcNow; DateTime dateTimeNow = DateTime.Today; // Display current times Debug.Print("Machine time = " + machineTimeNow.ToString()); Debug.Print("Local time = " + localTimeNow.ToString()); Debug.Print("UTC time = " + utcTimeNow.ToString()); Debug.Print("Today = " + dateTimeNow.ToString()); } public static void Main() { // Display current times DisplayTime(); // Set the local time System.DateTime dt = new System.DateTime(2014, 02, 16, 13, 50, 30); Debug.Print("Setting local time with: " + dt.ToString()); Microsoft.SPOT.Hardware.Utility.SetLocalTime(dt); // Display current times DisplayTime(); Debug.Print("Done"); // Set breakpoint here to hold output window open } }}
Gives following output:
Machine time = 01:02:23.9064746Local time = 06/01/2011 01:02:23UTC time = 06/01/2011 01:02:23Today = 06/01/2011 00:00:00Setting local time with: 02/16/2014 13:50:30Machine time = 01:02:23.9760426Local time = 02/16/2014 13:50:30UTC time = 02/16/2014 13:50:30Today = 02/16/2014 00:00:00
Hope this saves someone some time searching!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users