Time Library Example Won't Compile

In trying to debug some RTC code I am working on, I decided to go back to the basics and pasted the code from the TimeRTC.pde example that is included in the Time library download, but I can't get it to compile. I am getting the following messages:

In file included from Simple_RTC.cpp:9:
/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:17: error: 'time_t' does not name a type
/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:18: error: 'time_t' has not been declared
/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:19: error: 'tmElements_t' has not been declared
/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:20: error: 'tmElements_t' has not been declared
Simple_RTC.cpp: In function 'void setup()':
Simple_RTC:12: error: 'class DS1307RTC' has no member named 'get'
Simple_RTC:12: error: 'setSyncProvider' was not declared in this scope
Simple_RTC:13: error: 'timeStatus' was not declared in this scope
Simple_RTC:13: error: 'timeSet' was not declared in this scope
Simple_RTC.cpp: In function 'void digitalClockDisplay()':
Simple_RTC:27: error: 'hour' was not declared in this scope
Simple_RTC:28: error: 'minute' was not declared in this scope
Simple_RTC:29: error: 'second' was not declared in this scope
Simple_RTC:31: error: 'day' was not declared in this scope
Simple_RTC:33: error: 'month' was not declared in this scope
Simple_RTC:35: error: 'year' was not declared in this scope

The libraries, Wire, Time and DS1307RTC have been imported. I have tried refreshing the libraries to see if they have changed but still nothing.

Looks like Time library is not imported or included

I don't think that the Time library has been updated for 1.0+ use. You'll need to edit the header file, and change WProgram.h to Arduino.h.

PaulS:
I don't think that the Time library has been updated for 1.0+ use. You'll need to edit the header file, and change WProgram.h to Arduino.h.

The library at Arduino Playground - HomePage (Arduino Playground - HomePage) is OK for 1.0+

Time.cpp includes the code:

#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

I have downloaded and installed 1.0.5 and refreshed the time library again without change. Should I see an Arduino.h and Arduino.cpp in my libraries folder?

I would check to make sure my library files are on the root of the of the "libraries" folder.
meaning:

  1. download library zip
  2. Unzip the library folder into "libraries" folder in your main Arduino folder
  3. go inside unzipped folder and copy the folder that contains all the cpp and h files and paste it in the main "libraries" folder.

This has caused me trouble more than once.. hope it helps!

Should I see an Arduino.h and Arduino.cpp in my libraries folder?

No.

Time.cpp includes the code:

But, it is DS1307RTC.h that is causing the error. Is DS1307RTC.h compatible with 1.0+?

Gustermaximus:
I would check to make sure my library files are on the root of the of the "libraries" folder.
meaning:

  1. download library zip
  2. Unzip the library folder into "libraries" folder in your main Arduino folder
  3. go inside unzipped folder and copy the folder that contains all the cpp and h files and paste it in the main "libraries" folder.

This has caused me trouble more than once.. hope it helps!

Brilliant - thank you so much

Hey

I am having the same problem

I have tried the above but I still just get errors in the compiler.

I got a Real Time Clock Module and am trying to use it.

I am attempting to use the Example: DS1307RTC > ReadTest. (below)
All I get is error messages, it won't compile
how do I make it work

#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>

void setup() {
  Serial.begin(9600);
  while (!Serial) ; // wait for serial
  delay(200);
  Serial.println("DS1307RTC Read Test");
  Serial.println("-------------------");
}

void loop() {
  tmElements_t tm;

  if (RTC.read(tm)) {
    Serial.print("Ok, Time = ");
    print2digits(tm.Hour);
    Serial.write(':');
    print2digits(tm.Minute);
    Serial.write(':');
    print2digits(tm.Second);
    Serial.print(", Date (D/M/Y) = ");
    Serial.print(tm.Day);
    Serial.write('/');
    Serial.print(tm.Month);
    Serial.write('/');
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.println();
  } else {
    if (RTC.chipPresent()) {
      Serial.println("The DS1307 is stopped.  Please run the SetTime");
      Serial.println("example to initialize the time and begin running.");
      Serial.println();
    } else {
      Serial.println("DS1307 read error!  Please check the circuitry.");
      Serial.println();
    }
    delay(9000);
  }
  delay(1000);
}

void print2digits(int number) {
  if (number >= 0 && number < 10) {
    Serial.write('0');
  }
  Serial.print(number);
}

Try:

#include <Time.h>
#include <DS1307RTC.h>
#include <Wire.h>

I already have that at the top of the code
(and tried changing the order as your reply says: no effect)

All I get is error messages, it won't compile
how do I make it work

Simple. Fix all the errors. If you need help, I suspect that ACTUALLY telling us what you see is going to prove more helpful that whining.

Hey everyone, I'm new to Arduino and trying to channel my C/C++ from college many moons ago.

I am running Arduino 1.0.5 on Windows Vista 64, using an Arduino UNO on USB (COM5).

I have been trying to get the TimeSerial sketch to compile and the problem, at least from what I see, definitely lies in the Time.cpp file. I cleaned it up a bit by changing the original

#if ARDUINO >= 100
#include <Arduino.h> 
#else
#include <WProgram.h> 
#endif

#include "Time.h"

which gave me this error when verified in Arduino:

Time.cpp:30:18: error: Time.h: No such file or directory
Time.cpp:32: error: 'tmElements_t' does not name a type
Time.cpp:33: error: 'time_t' does not name a type
Time.cpp:34: error: 'time_t' does not name a type
Time.cpp:36: error: variable or field 'refreshCache' declared void
Time.cpp:36: error: 'time_t' was not declared in this scope

with:

#include <Arduino.h> 

#include <Time.h>

which then gave me this error:

Time.cpp:28: error: 'tmElements_t' does not name a type
Time.cpp:29: error: 'time_t' does not name a type
Time.cpp:30: error: 'time_t' does not name a type
Time.cpp:32: error: variable or field 'refreshCache' declared void
Time.cpp:32: error: 'time_t' was not declared in this scope

You'll notice getting rid of the "Time.h" for <Time.h> got rid of the "no such file or directory" issue.

Now, this leaves this segment of the code:

static tmElements_t tm;          // a cache of time elements
static time_t       cacheTime;   // the time the cache was updated
static time_t       syncInterval = 300;  // time sync will be attempted after this many seconds

which I think is directly responsible for all of the errors. I'm not very good when it comes to defining data types that aren't "int" , "double", or "float", etc. I'm assuming that the time data is going to be integers, but I don't know what types I should be defining here. I read the reference page on "static" and I should be able to define "static int tmElements_t" for example, but what is going on with the additional elements on those lines "tm", "cacheTime", and "syncInterval", etc.

I'm pretty sure if I can fix this part of the Time.cpp file, then I can finally get this sketch and others where I'm syncing the Arduino clock via the serial monitor should work.

Thanks in advance. Sorry this is my first post, but I guess you gotta start somewhere, and I didn't have a problem getting LEDs to blink or DC motors to run :slight_smile: At least I didn't start a new thread.

Post the sketch you are trying to compile. I really don't care that it is an example. Post it anyway.

Post your complete Time.cpp and Time.h files.

Describe EXACTLY where your sketch lives, and where your Time.h and Time.cpp files live.

My version of Time.cpp contains:

#if ARDUINO >= 100
#include <Arduino.h> 
#else
#include <WProgram.h> 
#endif

#include "Time.h"

and compiles just fine. The compiler IS able to find Time.h, because I installed the library correctly.

I went to Arduino Playground - HomePage and downloaded the Time.zip. I left it in the zip file and used the Sketch -> Import Library -> Add Library function, found the Time.zip file and successfully got the "Library added to your libraries. Check "Import library" menu". The library files now reside in my Documents/Arduino/libraries folder (not my Program(x86)/Arduino folder).

This is the TimeSerial sketch. I've read that last Serial.print(TIME_REQUEST,BYTE); should have the ",BYTE" removed from it, but I'll cross that bridge when I know the library files are fixed.

#include <Time.h>  

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER  'T'   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message 

void setup()  {
  Serial.begin(9600);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
}

void loop(){    
  if(Serial.available() ) 
  {
    processSyncMessage();
  }
  if(timeStatus()!= timeNotSet)   
  {
    digitalWrite(13,timeStatus() == timeSet); // on if synced, off if needs refresh  
    digitalClockDisplay();  
  }
  delay(1000);
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void processSyncMessage() {
  // if time sync available from serial port, update time and return true
  while(Serial.available() >=  TIME_MSG_LEN ){  // time message consists of a header and ten ascii digits
    char c = Serial.read() ; 
    Serial.print(c);  
    if( c == TIME_HEADER ) {       
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){   
        c = Serial.read();          
        if( c >= '0' && c <= '9'){   
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
        }
      }   
      setTime(pctime);   // Sync Arduino clock to the time received on the serial port
    }  
  }
}

time_t requestSync()
{
  Serial.print(TIME_REQUEST,BYTE);  
  return 0; // the time will be sent later in response to serial mesg
}

My Time.cpp file

/*
  time.c - low level time and date functions
  Copyright (c) Michael Margolis 2009

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  
  6  Jan 2010 - initial release 
  12 Feb 2010 - fixed leap year calculation error
  1  Nov 2010 - fixed setTime bug (thanks to Korman for this)
*/

#include <Arduino.h> 

#include <Time.h>

static tmElements_t tm;          // a cache of time elements
static time_t       cacheTime;   // the time the cache was updated
static time_t       syncInterval = 300;  // time sync will be attempted after this many seconds

void refreshCache( time_t t){
  if( t != cacheTime)
  {
    breakTime(t, tm); 
    cacheTime = t; 
  }
}

int hour() { // the hour now 
  return hour(now()); 
}

int hour(time_t t) { // the hour for the given time
  refreshCache(t);
  return tm.Hour;  
}

int hourFormat12() { // the hour now in 12 hour format
  return hourFormat12(now()); 
}

int hourFormat12(time_t t) { // the hour for the given time in 12 hour format
  refreshCache(t);
  if( tm.Hour == 0 )
    return 12; // 12 midnight
  else if( tm.Hour  > 12)
    return tm.Hour - 12 ;
  else
    return tm.Hour ;
}

uint8_t isAM() { // returns true if time now is AM
  return !isPM(now()); 
}

uint8_t isAM(time_t t) { // returns true if given time is AM
  return !isPM(t);  
}

uint8_t isPM() { // returns true if PM
  return isPM(now()); 
}

uint8_t isPM(time_t t) { // returns true if PM
  return (hour(t) >= 12); 
}

int minute() {
  return minute(now()); 
}

int minute(time_t t) { // the minute for the given time
  refreshCache(t);
  return tm.Minute;  
}

int second() {
  return second(now()); 
}

int second(time_t t) {  // the second for the given time
  refreshCache(t);
  return tm.Second;
}

int day(){
  return(day(now())); 
}

int day(time_t t) { // the day for the given time (0-6)
  refreshCache(t);
  return tm.Day;
}

int weekday() {   // Sunday is day 1
  return  weekday(now()); 
}

int weekday(time_t t) {
  refreshCache(t);
  return tm.Wday;
}
   
int month(){
  return month(now()); 
}

int month(time_t t) {  // the month for the given time
  refreshCache(t);
  return tm.Month;
}

int year() {  // as in Processing, the full four digit year: (2009, 2010 etc) 
  return year(now()); 
}

int year(time_t t) { // the year for the given time
  refreshCache(t);
  return tmYearToCalendar(tm.Year);
}

/*============================================================================*/	
/* functions to convert to and from system time */
/* These are for interfacing with time serivces and are not normally needed in a sketch */

// leap year calulator expects year argument as years offset from 1970
#define LEAP_YEAR(Y)     ( ((1970+Y)>0) && !((1970+Y)%4) && ( ((1970+Y)%100) || !((1970+Y)%400) ) )

static  const uint8_t monthDays[]={31,28,31,30,31,30,31,31,30,31,30,31}; // API starts months from 1, this array starts from 0
 
void breakTime(time_t time, tmElements_t &tm){
// break the given time_t into time components
// this is a more compact version of the C library localtime function
// note that year is offset from 1970 !!!

  uint8_t year;
  uint8_t month, monthLength;
  unsigned long days;
  
  tm.Second = time % 60;
  time /= 60; // now it is minutes
  tm.Minute = time % 60;
  time /= 60; // now it is hours
  tm.Hour = time % 24;
  time /= 24; // now it is days
  tm.Wday = ((time + 4) % 7) + 1;  // Sunday is day 1 
  
  year = 0;  
  days = 0;
  while((unsigned)(days += (LEAP_YEAR(year) ? 366 : 365)) <= time) {
    year++;
  }
  tm.Year = year; // year is offset from 1970 
  
  days -= LEAP_YEAR(year) ? 366 : 365;
  time  -= days; // now it is days in this year, starting at 0
  
  days=0;
  month=0;
  monthLength=0;
  for (month=0; month<12; month++) {
    if (month==1) { // february
      if (LEAP_YEAR(year)) {
        monthLength=29;
      } else {
        monthLength=28;
      }
    } else {
      monthLength = monthDays[month];
    }
    
    if (time >= monthLength) {
      time -= monthLength;
    } else {
        break;
    }
  }
  tm.Month = month + 1;  // jan is month 1  
  tm.Day = time + 1;     // day of month
}

time_t makeTime(tmElements_t &tm){   
// assemble time elements into time_t 
// note year argument is offset from 1970 (see macros in time.h to convert to other formats)
// previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9
  
  int i;
  time_t seconds;

  // seconds from 1970 till 1 jan 00:00:00 of the given year
  seconds= tm.Year*(SECS_PER_DAY * 365);
  for (i = 0; i < tm.Year; i++) {
    if (LEAP_YEAR(i)) {
      seconds +=  SECS_PER_DAY;   // add extra days for leap years
    }
  }
  
  // add days for this year, months start from 1
  for (i = 1; i < tm.Month; i++) {
    if ( (i == 2) && LEAP_YEAR(tm.Year)) { 
      seconds += SECS_PER_DAY * 29;
    } else {
      seconds += SECS_PER_DAY * monthDays[i-1];  //monthDay array starts from 0
    }
  }
  seconds+= (tm.Day-1) * SECS_PER_DAY;
  seconds+= tm.Hour * SECS_PER_HOUR;
  seconds+= tm.Minute * SECS_PER_MIN;
  seconds+= tm.Second;
  return seconds; 
}
/*=====================================================*/	
/* Low level system time functions  */

static time_t sysTime = 0;
static time_t prevMillis = 0;
static time_t nextSyncTime = 0;
static timeStatus_t Status = timeNotSet;

getExternalTime getTimePtr;  // pointer to external sync function
//setExternalTime setTimePtr; // not used in this version

#ifdef TIME_DRIFT_INFO   // define this to get drift data
time_t sysUnsyncedTime = 0; // the time sysTime unadjusted by sync  
#endif


time_t now(){
  while( millis() - prevMillis >= 1000){      
    sysTime++;
    prevMillis += 1000;	
#ifdef TIME_DRIFT_INFO
    sysUnsyncedTime++; // this can be compared to the synced time to measure long term drift     
#endif	
  }
  if(nextSyncTime <= sysTime){
	if(getTimePtr != 0){
	  time_t t = getTimePtr();
      if( t != 0)
        setTime(t);
      else
        Status = (Status == timeNotSet) ?  timeNotSet : timeNeedsSync;        
    }
  }  
  return sysTime;
}

void setTime(time_t t){ 
#ifdef TIME_DRIFT_INFO
 if(sysUnsyncedTime == 0) 
   sysUnsyncedTime = t;   // store the time of the first call to set a valid Time   
#endif

  sysTime = t;  
  nextSyncTime = t + syncInterval;
  Status = timeSet; 
  prevMillis = millis();  // restart counting from now (thanks to Korman for this fix)
} 

void  setTime(int hr,int min,int sec,int dy, int mnth, int yr){
 // year can be given as full four digit year or two digts (2010 or 10 for 2010);  
 //it is converted to years since 1970
  if( yr > 99)
      yr = yr - 1970;
  else
      yr += 30;  
  tm.Year = yr;
  tm.Month = mnth;
  tm.Day = dy;
  tm.Hour = hr;
  tm.Minute = min;
  tm.Second = sec;
  setTime(makeTime(tm));
}

void adjustTime(long adjustment){
  sysTime += adjustment;
}

timeStatus_t timeStatus(){ // indicates if time has been set and recently synchronized
  return Status;
}

void setSyncProvider( getExternalTime getTimeFunction){
  getTimePtr = getTimeFunction;  
  nextSyncTime = sysTime;
  now(); // this will sync the clock
}

void setSyncInterval(time_t interval){ // set the number of seconds between re-sync
  syncInterval = interval;
}

My Time.h file

/*
  time.h - low level time and date functions
*/

/*
  July 3 2011 - fixed elapsedSecsThisWeek macro (thanks Vincent Valdy for this)
              - fixed  daysToTime_t macro (thanks maniacbug)
*/     

#ifndef _Time_h
#define _Time_h

#include <inttypes.h>

typedef unsigned long time_t;

typedef enum {timeNotSet, timeNeedsSync, timeSet
}  timeStatus_t ;

typedef enum {
    dowInvalid, dowSunday, dowMonday, dowTuesday, dowWednesday, dowThursday, dowFriday, dowSaturday
} timeDayOfWeek_t;

typedef enum {
    tmSecond, tmMinute, tmHour, tmWday, tmDay,tmMonth, tmYear, tmNbrFields
} tmByteFields;	   

typedef struct  { 
  uint8_t Second; 
  uint8_t Minute; 
  uint8_t Hour; 
  uint8_t Wday;   // day of week, sunday is day 1
  uint8_t Day;
  uint8_t Month; 
  uint8_t Year;   // offset from 1970; 
} 	tmElements_t, TimeElements, *tmElementsPtr_t;

//convenience macros to convert to and from tm years 
#define  tmYearToCalendar(Y) ((Y) + 1970)  // full four digit year 
#define  CalendarYrToTm(Y)   ((Y) - 1970)
#define  tmYearToY2k(Y)      ((Y) - 30)    // offset is from 2000
#define  y2kYearToTm(Y)      ((Y) + 30)   

typedef time_t(*getExternalTime)();
//typedef void  (*setExternalTime)(const time_t); // not used in this version


/*==============================================================================*/
/* Useful Constants */
#define SECS_PER_MIN  (60UL)
#define SECS_PER_HOUR (3600UL)
#define SECS_PER_DAY  (SECS_PER_HOUR * 24UL)
#define DAYS_PER_WEEK (7UL)
#define SECS_PER_WEEK (SECS_PER_DAY * DAYS_PER_WEEK)
#define SECS_PER_YEAR (SECS_PER_WEEK * 52UL)
#define SECS_YR_2000  (946684800UL) // the time at the start of y2k
 
/* Useful Macros for getting elapsed time */
#define numberOfSeconds(_time_) (_time_ % SECS_PER_MIN)  
#define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN) 
#define numberOfHours(_time_) (( _time_% SECS_PER_DAY) / SECS_PER_HOUR)
#define dayOfWeek(_time_)  ((( _time_ / SECS_PER_DAY + 4)  % DAYS_PER_WEEK)+1) // 1 = Sunday
#define elapsedDays(_time_) ( _time_ / SECS_PER_DAY)  // this is number of days since Jan 1 1970
#define elapsedSecsToday(_time_)  (_time_ % SECS_PER_DAY)   // the number of seconds since last midnight 
// The following macros are used in calculating alarms and assume the clock is set to a date later than Jan 1 1971
// Always set the correct time before settting alarms
#define previousMidnight(_time_) (( _time_ / SECS_PER_DAY) * SECS_PER_DAY)  // time at the start of the given day
#define nextMidnight(_time_) ( previousMidnight(_time_)  + SECS_PER_DAY )   // time at the end of the given day 
#define elapsedSecsThisWeek(_time_)  (elapsedSecsToday(_time_) +  ((dayOfWeek(_time_)-1) * SECS_PER_DAY) )   // note that week starts on day 1
#define previousSunday(_time_)  (_time_ - elapsedSecsThisWeek(_time_))      // time at the start of the week for the given time
#define nextSunday(_time_) ( previousSunday(_time_)+SECS_PER_WEEK)          // time at the end of the week for the given time


/* Useful Macros for converting elapsed time to a time_t */
#define minutesToTime_t ((M)) ( (M) * SECS_PER_MIN)  
#define hoursToTime_t   ((H)) ( (H) * SECS_PER_HOUR)  
#define daysToTime_t    ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011
#define weeksToTime_t   ((W)) ( (W) * SECS_PER_WEEK)   

/*============================================================================*/
/*  time and date functions   */
int     hour();            // the hour now 
int     hour(time_t t);    // the hour for the given time
int     hourFormat12();    // the hour now in 12 hour format
int     hourFormat12(time_t t); // the hour for the given time in 12 hour format
uint8_t isAM();            // returns true if time now is AM
uint8_t isAM(time_t t);    // returns true the given time is AM
uint8_t isPM();            // returns true if time now is PM
uint8_t isPM(time_t t);    // returns true the given time is PM
int     minute();          // the minute now 
int     minute(time_t t);  // the minute for the given time
int     second();          // the second now 
int     second(time_t t);  // the second for the given time
int     day();             // the day now 
int     day(time_t t);     // the day for the given time
int     weekday();         // the weekday now (Sunday is day 1) 
int     weekday(time_t t); // the weekday for the given time 
int     month();           // the month now  (Jan is month 1)
int     month(time_t t);   // the month for the given time
int     year();            // the full four digit year: (2009, 2010 etc) 
int     year(time_t t);    // the year for the given time

time_t now();              // return the current time as seconds since Jan 1 1970 
void    setTime(time_t t);
void    setTime(int hr,int min,int sec,int day, int month, int yr);
void    adjustTime(long adjustment);

/* date strings */ 
#define dt_MAX_STRING_LEN 9 // length of longest date string (excluding terminating null)
char* monthStr(uint8_t month);
char* dayStr(uint8_t day);
char* monthShortStr(uint8_t month);
char* dayShortStr(uint8_t day);
	
/* time sync functions	*/
timeStatus_t timeStatus(); // indicates if time has been set and recently synchronized
void    setSyncProvider( getExternalTime getTimeFunction); // identify the external time provider
void    setSyncInterval(time_t interval); // set the number of seconds between re-sync

/* low level functions to convert to and from system time                     */
void breakTime(time_t time, tmElements_t &tm);  // break time_t into elements
time_t makeTime(tmElements_t &tm);  // convert time elements into time_t


#endif /* _Time_h */

I went to Arduino Playground - HomePage and downloaded the Time.zip.

Good.

I left it in the zip file

Bad.

and used the Sketch -> Import Library -> Add Library function, found the Time.zip file and successfully got the "Library added to your libraries. Check "Import library" menu". The library files now reside in my Documents/Arduino/libraries folder (not my Program(x86)/Arduino folder).

I have no idea what that tool does. I have no idea whether it puts stuff in the right place.

Where are your sketches saved?

http://arduino.cc/en/Guide/Libraries says leaving in zip file is good, not bad. I installed it exactly as the instructions stated.

The sketches are saved in my Documents/Arduino folder (default Sketchbook save location).

http://arduino.cc/en/Guide/Libraries says leaving in zip file is good, not bad. I installed it exactly as the instructions stated.

And you are having problems.

I did not follow those instructions, and the code you posted compiles for me (after I remove the ,BYTE and change print() to write() on the one statement).