Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extracted all language specific data into separate header file to all… #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 29 additions & 30 deletions DateStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,46 @@
#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[] =
{
monthStr0,monthStr1,monthStr2,monthStr3,monthStr4,monthStr5,monthStr6,
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 */

Expand All @@ -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;
}

Expand All @@ -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;
}
43 changes: 43 additions & 0 deletions TimeINTL_DE.h
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions TimeINTL_EN.h
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion TimeLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <inttypes.h>
#ifndef __AVR__
#include <sys/types.h> // for __time_t_defined, but avr libc lacks sys/types.h
Expand Down Expand Up @@ -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);
Expand Down