time.h library can't seem to compile in IDE 1.5.7

I was trying to measure a thermistor over a long period of time (months) and wanted to save the data to a file. However, I did not want one huge file, so I was going to get the month and day, and automatically create a directory /month/day/temperature.dat file daily to record the data. However, I had no idea how to get the date and found the time.h library but have had problems.

I wrote the following code after following the instructions at the site

http://playground.arduino.cc/Code/Time

I imported the time library and then loaded the library into the sketch under sketch->import library->time.

#include <Time.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

However, when I verify the sketch, I get the following errors:

Arduino: 1.5.7 (Windows 7), Board: "Arduino Uno"

Build options changed, rebuilding all

In file included from C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:10:0:
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:18:18: error: variable 'monthStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr1[] PROGMEM = "January";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:19:18: error: variable 'monthStr2' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr2[] PROGMEM = "February";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:20:18: error: variable 'monthStr3' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr3[] PROGMEM = "March";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:21:18: error: variable 'monthStr4' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr4[] PROGMEM = "April";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:22:18: error: variable 'monthStr5' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr5[] PROGMEM = "May";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:23:18: error: variable 'monthStr6' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr6[] PROGMEM = "June";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:24:18: error: variable 'monthStr7' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr7[] PROGMEM = "July";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:25:18: error: variable 'monthStr8' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr8[] PROGMEM = "August";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:26:18: error: variable 'monthStr9' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr9[] PROGMEM = "September";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:27:19: error: variable 'monthStr10' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr10[] PROGMEM = "October";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:28:19: error: variable 'monthStr11' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr11[] PROGMEM = "November";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:29:19: error: variable 'monthStr12' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr12[] PROGMEM = "December";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:31:22: error: variable 'monthNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
PGM_P monthNames_P[] PROGMEM =
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:37:26: error: variable 'monthShortNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthShortNames_P[] PROGMEM = "ErrJanFebMarAprMayJunJulAugSepOctNovDec";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:39:16: error: variable 'dayStr0' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr0[] PROGMEM = "Err";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:40:16: error: variable 'dayStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr1[] PROGMEM = "Sunday";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:41:16: error: variable 'dayStr2' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr2[] PROGMEM = "Monday";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:42:16: error: variable 'dayStr3' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr3[] PROGMEM = "Tuesday";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:43:16: error: variable 'dayStr4' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr4[] PROGMEM = "Wednesday";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:44:16: error: variable 'dayStr5' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr5[] PROGMEM = "Thursday";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:45:16: error: variable 'dayStr6' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr6[] PROGMEM = "Friday";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:46:16: error: variable 'dayStr7' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr7[] PROGMEM = "Saturday";
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:48:20: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
PGM_P dayNames_P[] PROGMEM = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
^
C:\Users\Michael\Documents\Arduino\libraries\Time\DateStrings.cpp:49:24: error: variable 'dayShortNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThrFriSat";
^

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Okay, so I am wondering if the errors I am seeing are due to my IDE version, the time library, or something else? Obviously, I have been battling this for a while, not sure what I am doing wrong. Open to ideas.

However, when I verify the sketch, I get the following errors:

Which clearly you didn't bother searching for. This issue has already been discussed many times - the latest one THIS week.

The message itself tells you EXACTLY what the problem is, and provides a HUGE clue as to how to fix it. The declaration needs to have const added at the beginning. Fire up a text editor and get busy.

Open the file DateStrings.cpp in your libraries/Time folder.

Change the PROGMEM lines to look like this:

const char monthStr1[] PROGMEM = "January";
const char monthStr2[] PROGMEM = "February";
const char monthStr3[] PROGMEM = "March";
const char monthStr4[] PROGMEM = "April";
const char monthStr5[] PROGMEM = "May";
const char monthStr6[] PROGMEM = "June";
const char monthStr7[] PROGMEM = "July";
const char monthStr8[] PROGMEM = "August";
const char monthStr9[] PROGMEM = "September";
const char monthStr10[] PROGMEM = "October";
const char monthStr11[] PROGMEM = "November";
const char monthStr12[] PROGMEM = "December";

const char * const monthNames_P[] PROGMEM = 
{
    "",monthStr1,monthStr2,monthStr3,monthStr4,monthStr5,monthStr6,
	monthStr7,monthStr8,monthStr9,monthStr10,monthStr11,monthStr12
};

const char monthShortNames_P[] PROGMEM = "ErrJanFebMarAprMayJunJulAugSepOctNovDec";

const char dayStr0[] PROGMEM = "Err";
const char dayStr1[] PROGMEM = "Sunday";
const char dayStr2[] PROGMEM = "Monday";
const char dayStr3[] PROGMEM = "Tuesday";
const char dayStr4[] PROGMEM = "Wednesday";
const char dayStr5[] PROGMEM = "Thursday";
const char dayStr6[] PROGMEM = "Friday";
const char dayStr7[] PROGMEM = "Saturday";

const char * const dayNames_P[] PROGMEM = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
const char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThrFriSat";

Then it compiles OK.

I haven't tested it running.

Nick, thanks for the response, that got Time.h library working. I was confused because I thought libraries referenced by the arduino.cc site would just "work". I have never coded in c++ and have used libraries very minimally. Also, I know with VBA, if I can get a whole series of errors by turning Option Explicit on, and thought there might be something like that for the code in the Time.h library. Anyways, I am pretty certain I would not of solved that without your help.

Is this an issue with the library, arduino IDE, or just the way things are? Would this problem crop up if the library was being used for other cpp programs outside of arduino? I am just wondering how I would know how to address this issue outside of coming across it in the forums of arduino.

Also, I searched the arduino forums for "Time.h", but even though it is in quotes, it would search instead for "time" and "h". Accordingly, I was not getting relevant searches (even though it shows the use of quotes in the search textbox). This makes it difficult to search for information on particular libraries if they have common names.

The 1.5.7+ versions of the IDE are beta. Also they have a version of the avr-g++ compiler that is more strict with syntax. This is an occupational hazard for coders everywhere (not just Arduino) as they find that code that previously worked now is caught up in stricter rules.

In particular, a large number of Arduino libraries will have been written that may well fail unless things are rejigged a bit because of this.

Also, I searched the arduino forums for "Time.h", but even though it is in quotes, it would search instead for "time" and "h".

Don't use the Forum Search facility, it's completely useless. Use Google, like this:

time.h site:arduino.cc

Narrowing down to a particular site is a useful trick to use with Google.

Would this problem crop up if the library was being used for other cpp programs outside of arduino?

Depends which version of the compiler they use. Quite possibly.

Thanks for your response.