get date/time from the local computer

Status
Not open for further replies.

WAD

Member
Have a teensy 2.0, how do I get the local pc's date/time and store it in a variable/s ?

I will be using the teensy as an hid keyboard.

(very noob with Teensy)

WAD
 
Im getting the below error when compiling the DateTime example.

TimeSerialDateStrings:59: error: 'DateTimeStrings' was not declared in this scope

Any ideas anyone ?
 
Im getting the below error when compiling the DateTime example.

DateTime.pde: In function 'void loop()':
DateTime:19: error: 'DateTime' was not declared in this scope
DateTime:21: error: 'DateTime' was not declared in this scope
DateTime.pde: In function 'boolean getPCtime()':
DateTime:41: error: 'time_t' was not declared in this scope
DateTime:41: error: expected `;' before 'pctime'
DateTime:45: error: 'pctime' was not declared in this scope
DateTime:48: error: 'DateTime' was not declared in this scope
DateTime:48: error: 'pctime' was not declared in this scope
DateTime.pde: In function 'void digitalClockDisplay()':
DateTime:57: error: 'DateTime' was not declared in this scope
DateTime:61: error: 'DateTimeStrings' was not declared in this scope

Any ideas anyone ?
 
If I'm not mistaken the default output is set to Serial.print();
You'll have to open the Serial Monitor to see it being printed (top-right corner of the Arduino window or press CTRl-SHIFT-M).
 
I opened the serial monitor and see nothing. As a guess, I replaced serial.print with keyboard.print , still no go.
 
Hmm, I don't have a T2 so I can't rly compare tests..
I am wondering if Teensy as a HID interface can actually interface with the Serial Monitor?
Does the example with Serial.print() work when you set the Teensy as a Serial device ?

Just tested this on a T3, Serial.print does work on HID setting...

Also, I think you already got this but just to make sure, you need a Serial driver (included in the latest Teensyduino installer though).

Other than that I'm out of ideas at the moment, sry
 
Last edited:
I need to test the teensy as serial device. I will post my results in here. This might be partly due to me having gotten my hands on the teensy for the first time yesterday and I need more time with it. Thanks for the suggestions ZTiK.
 
Sorry, this time stuff is something of a mess, and it's my fault. Well, sort of my fault....

When Teensy 3.0 came out, the Time library didn't work. It turns out there's a conflict between "time_t" in the library, and newlib's "time_t", which follows the POSIX standards. I exchanged several emails with Michael Margolis, author of the Time library. He preferred changing it to "atime_t". The Time library that comes with Teensyduino right now has that change.

Unfortunately, there are some other related Time libraries still using time_t. Also, it turns out there are quite a few people who feel very strongly about not changing the name. I'm starting to feel like the change was a mistake. I'm planning to revisit Time soon, probably putting it back to time_t. Someone recently suggested to me the possibility of using a "__time_t_defined" macro to automatically deal with the compatibility issues (where "automatically" is me writing a bunch of code so you never have to worry or even know about these issues).

So, first of all, I'm sorry this is such a mess. It's on my to-do list. So are lots of other things, and right now I'm finishing up a WS2811 LED library, so it'll be a while until I really work on this.

In the meantime, if you're using Teensy 2.0, the simplest thing to do is delete the Time library that came with Teensyduino (the one containing "atime_t", and replace it with the older copy found on the Arduino Playground. That should get you up and running.
 
Status
Not open for further replies.
Back
Top