diff --git a/DateStrings.cpp b/DateStrings.cpp index 3eccff3..18cc8b9 100644 --- a/DateStrings.cpp +++ b/DateStrings.cpp @@ -23,23 +23,22 @@ #include "TimeLib.h" // the short strings for each day or month must be exactly dt_SHORT_STR_LEN -#define dt_SHORT_STR_LEN 3 // the length of short strings static char buffer[dt_MAX_STRING_LEN+1]; // must be big enough for longest string and the terminating null -const char monthStr0[] PROGMEM = ""; -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 monthStr0[] PROGMEM = TimeINTL_nothing; +const char monthStr1[] PROGMEM = TimeINTL_january; +const char monthStr2[] PROGMEM = TimeINTL_february; +const char monthStr3[] PROGMEM = TimeINTL_march; +const char monthStr4[] PROGMEM = TimeINTL_april; +const char monthStr5[] PROGMEM = TimeINTL_mai; +const char monthStr6[] PROGMEM = TimeINTL_june; +const char monthStr7[] PROGMEM = TimeINTL_july; +const char monthStr8[] PROGMEM = TimeINTL_august; +const char monthStr9[] PROGMEM = TimeINTL_september; +const char monthStr10[] PROGMEM = TimeINTL_october; +const char monthStr11[] PROGMEM = TimeINTL_november; +const char monthStr12[] PROGMEM = TimeINTL_december; const PROGMEM char * const PROGMEM monthNames_P[] = { @@ -47,23 +46,23 @@ const PROGMEM char * const PROGMEM monthNames_P[] = monthStr7,monthStr8,monthStr9,monthStr10,monthStr11,monthStr12 }; -const char monthShortNames_P[] PROGMEM = "ErrJanFebMarAprMayJunJulAugSepOctNovDec"; +const char monthShortNames_P[] PROGMEM = TimeINTL_short_month; -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 dayStr0[] PROGMEM = TimeINTL_err; +const char dayStr1[] PROGMEM = TimeINTL_sunday; +const char dayStr2[] PROGMEM = TimeINTL_monday; +const char dayStr3[] PROGMEM = TimeINTL_tuesday; +const char dayStr4[] PROGMEM = TimeINTL_wednesday; +const char dayStr5[] PROGMEM = TimeINTL_thursday; +const char dayStr6[] PROGMEM = TimeINTL_friday; +const char dayStr7[] PROGMEM = TimeINTL_saturday; const PROGMEM char * const PROGMEM dayNames_P[] = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7 }; -const char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThuFriSat"; +const char dayShortNames_P[] PROGMEM = TimeINTL_short_days; /* functions to return date strings */ @@ -75,9 +74,9 @@ char* monthStr(uint8_t month) char* monthShortStr(uint8_t month) { - for (int i=0; i < dt_SHORT_STR_LEN; i++) - buffer[i] = pgm_read_byte(&(monthShortNames_P[i+ (month*dt_SHORT_STR_LEN)])); - buffer[dt_SHORT_STR_LEN] = 0; + for (int i=0; i < dt_SHORT_MON_LEN; i++) + buffer[i] = pgm_read_byte(&(monthShortNames_P[i+ (month*dt_SHORT_MON_LEN)])); + buffer[dt_SHORT_MON_LEN] = 0; return buffer; } @@ -89,9 +88,9 @@ char* dayStr(uint8_t day) char* dayShortStr(uint8_t day) { - uint8_t index = day*dt_SHORT_STR_LEN; - for (int i=0; i < dt_SHORT_STR_LEN; i++) + uint8_t index = day*dt_SHORT_DAY_LEN; + for (int i=0; i < dt_SHORT_DAY_LEN; i++) buffer[i] = pgm_read_byte(&(dayShortNames_P[index + i])); - buffer[dt_SHORT_STR_LEN] = 0; + buffer[dt_SHORT_DAY_LEN] = 0; return buffer; } diff --git a/TimeINTL_DE.h b/TimeINTL_DE.h new file mode 100644 index 0000000..7ca264c --- /dev/null +++ b/TimeINTL_DE.h @@ -0,0 +1,43 @@ +/********************************** + * + * International names and abbrevations for date/time items + * GERMAN/DEUTSCH + * + **********************************/ +#ifndef _TimeINTL_h +#define _TimeINTL_h + +#define _Time_INTL_ISO "DE" + +#define dt_MAX_STRING_LEN 10 // length of longest date string (excluding terminating null) +#define dt_SHORT_MON_LEN 3 // the length of short month strings +#define dt_SHORT_DAY_LEN 2 // the length of short day strings + +#define TimeINTL_nothing "" +#define TimeINTL_january "Januar" +#define TimeINTL_february "Februar" +#define TimeINTL_march "März" +#define TimeINTL_april "April" +#define TimeINTL_mai "Mai" +#define TimeINTL_june "Juni" +#define TimeINTL_july "Juli" +#define TimeINTL_august "August" +#define TimeINTL_september "September" +#define TimeINTL_october "Oktober" +#define TimeINTL_november "November" +#define TimeINTL_december "Dezember" + +#define TimeINTL_short_month "ErrJanFebM\xE4rAprMaiJunJulAugSepOktNovDez" + +#define TimeINTL_err "!!" +#define TimeINTL_sunday "Sonntag" +#define TimeINTL_monday "Montag" +#define TimeINTL_tuesday "Dienstag" +#define TimeINTL_wednesday "Mittwoch" +#define TimeINTL_thursday "Donnerstag" +#define TimeINTL_friday "Freitag" +#define TimeINTL_saturday "Samstag" + +#define TimeINTL_short_days "!!SoMoDiMiDoFrSa" + +#endif \ No newline at end of file diff --git a/TimeINTL_EN.h b/TimeINTL_EN.h new file mode 100644 index 0000000..7a4f25a --- /dev/null +++ b/TimeINTL_EN.h @@ -0,0 +1,43 @@ +/********************************** + * + * International names and abbrevations for date/time items + * ENGLISH (migrated from original code) + * + **********************************/ +#ifndef _TimeINTL_h +#define _TimeINTL_h + +#define _Time_INTL_ISO "EN" + +#define dt_MAX_STRING_LEN 9 // length of longest date string (excluding terminating null) +#define dt_SHORT_MON_LEN 3 // the length of short month strings +#define dt_SHORT_DAY_LEN 3 // the length of short day strings + +#define TimeINTL_nothing "" +#define TimeINTL_january "January" +#define TimeINTL_february "February" +#define TimeINTL_march "March" +#define TimeINTL_april "April" +#define TimeINTL_mai "May" +#define TimeINTL_june "June" +#define TimeINTL_july "July" +#define TimeINTL_august "August" +#define TimeINTL_september "September" +#define TimeINTL_october "October" +#define TimeINTL_november "November" +#define TimeINTL_december "December" + +#define TimeINTL_short_month "ErrJanFebMarAprMayJunJulAugSepOctNovDec" + +#define TimeINTL_err "Err" +#define TimeINTL_sunday "Sunday" +#define TimeINTL_monday "Monday" +#define TimeINTL_tuesday "Tuesday" +#define TimeINTL_wednesday "Wednesday" +#define TimeINTL_thursday "Thursday" +#define TimeINTL_friday "Friday" +#define TimeINTL_saturday "Saturday" + +#define TimeINTL_short_days "!!SoMoDiMiDoFrSa" + +#endif \ No newline at end of file diff --git a/TimeLib.h b/TimeLib.h index ddb1668..f7e6b7d 100644 --- a/TimeLib.h +++ b/TimeLib.h @@ -7,10 +7,18 @@ - fixed daysToTime_t macro (thanks maniacbug) */ + #ifndef _Time_h #ifdef __cplusplus #define _Time_h + +//#ifndef _TimeINTL_h +//#define _TimeINTL_h +#include "TimeINTL_DE.h" +//#endif // _TimeINTL_h + + #include #ifndef __AVR__ #include // for __time_t_defined, but avr libc lacks sys/types.h @@ -123,7 +131,7 @@ 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);