void print_date(int yPos) { for(int x = 0; x<128; x++) { for(int y=yPos; y<yPos+18; y++ ){ reset_pixel(x,y); } } /*int dayWidth = get_dayWidth(); int monthWidth = get_monthWidth(); int dateWidth = dayWidth + monthWidth + 6; //6=Punkt + Leerzeichen int xPosDate = (127 - dateWidth) / 2 + 1;*/ int xPosDate = get_dateXPos(); if ((yPos == POS_DATE_STD) && (day==14) && (month==1)){ uint8_t roseSymb[90]; for(int i=0; i<90; i++){ roseSymb[i] = pgm_read_byte(&rose[0][i]); } print_symbol(16, 45, roseSymb, (127 - ROSE_WIDTH) / 2 + 1, POS_DATE_STD); } else if ((yPos == POS_DATE_STD) && (day==4) && (month==7)) { int spruch [11]; convertString("Alles Liebe", spruch); int xSpruch = (127 - get_stringWidth(spruch, 11)) / 2 + 1; print_ASCIIString(xSpruch, POS_DATE_STD, spruch, 11); uint8_t herzSymb[32]; for(int i=0; i<32; i++){ herzSymb[i] = pgm_read_byte(&herz[0][i]); } print_symbol(16, 16, herzSymb, xSpruch - 16 - 4, POS_DATE_STD); print_symbol(16, 16, herzSymb, xSpruch + get_stringWidth(spruch, 11) + 4, POS_DATE_STD); } else { print_day(xPosDate, yPos); //Tag print_letter(alphaHeight, pgm_read_byte(&alphaWidth[54]), 54, xPosDate + get_dayWidth() + 1, yPos); //Punkt print_month(xPosDate + get_dayWidth() + 6, yPos); //Monat ..+6=Punkt+Leerzeichen } }
void print_date(uint8_t month, uint8_t day, uint8_t year, uint8_t mode) { displaySetAddress(MENU_INDENT, 3); displayPutStr("Date:", NORMAL); if (region == REGION_US) { displayPutStr(" ",NORMAL); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); } else if (region == REGION_EU) { displayPutStr(" ",NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); } else if ( region == DOW_REGION_US) { displayWriteChar(' ', NORMAL); print_dow(NORMAL,month,day,year); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); } else if ( region == DOW_REGION_EU) { displayWriteChar(' ', NORMAL); print_dow(NORMAL,month,day,year); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); printnumber(month, (mode == SET_MONTH)?INVERTED:NORMAL); displayWriteChar('/', NORMAL); } else if ( region == DATELONG) { displayPutStr(" ",NORMAL); print_month((mode == SET_MONTH)?INVERTED:NORMAL,month); displayWriteChar(' ', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); displayWriteChar(',', NORMAL); displayWriteChar(' ', NORMAL); } else { print_dow(NORMAL,month,day,year); print_month((mode == SET_MONTH)?INVERTED:NORMAL,month); displayWriteChar(' ', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); displayWriteChar(',', NORMAL); } printnumber(20,(mode == SET_YEAR)?INVERTED:NORMAL); printnumber(year, (mode == SET_YEAR)?INVERTED:NORMAL); }
void print_date(uint8_t month, uint8_t day, uint8_t year, uint8_t mode) { glcdSetAddress(MENU_INDENT, 3); glcdPutStr("Date:", NORMAL); if (region == REGION_US) { glcdPutStr(" ",NORMAL); print_number_slash(month,(mode == SET_MONTH)?INVERTED:NORMAL); print_number_slash(day, (mode == SET_DAY)?INVERTED:NORMAL); } else if (region == REGION_EU) { glcdPutStr(" ",NORMAL); print_number_slash(day, (mode == SET_DAY)?INVERTED:NORMAL); print_number_slash(month,(mode == SET_MONTH)?INVERTED:NORMAL); } #ifdef OPTION_DOW_DATELONG else if ( region == DOW_REGION_US) { glcdWriteChar(' ', NORMAL); print_dow(NORMAL,month,day,year); print_number_slash(month,(mode == SET_MONTH)?INVERTED:NORMAL); print_number_slash(day, (mode == SET_DAY)?INVERTED:NORMAL); } else if ( region == DOW_REGION_EU) { glcdWriteChar(' ', NORMAL); print_dow(NORMAL,month,day,year); print_number_slash(day, (mode == SET_DAY)?INVERTED:NORMAL); print_number_slash(month,(mode == SET_MONTH)?INVERTED:NORMAL); } else if ( region == DATELONG) { glcdPutStr(" ",NORMAL); print_month((mode == SET_MONTH)?INVERTED:NORMAL,month); glcdWriteChar(' ', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar(',', NORMAL); glcdWriteChar(' ', NORMAL); } else { print_dow(NORMAL,month,day,year); print_month((mode == SET_MONTH)?INVERTED:NORMAL,month); glcdWriteChar(' ', NORMAL); printnumber(day, (mode == SET_DAY)?INVERTED:NORMAL); glcdWriteChar(',', NORMAL); } #endif printnumber(20,(mode == SET_YEAR)?INVERTED:NORMAL); printnumber(year, (mode == SET_YEAR)?INVERTED:NORMAL); }
main(int argc, char *argv[]) { void print_month(int month, int year); int month = atoi(argv[1]); int year = atoi(argv[2]); if ((month < 1 || month > 12) || year < 0){ printf("Please enter a valid month and year as arguments\n"); return 0; } else print_month(month, year); }
static void cal(int32_t month, int32_t year, UBool useLongNames, UErrorCode *status) { UCalendar *c; UChar *days [DAY_COUNT]; UChar *months [MONTH_COUNT]; int32_t fdow; if(U_FAILURE(*status)) return; /* Create a new calendar */ c = ucal_open(0, -1, uloc_getDefault(), UCAL_TRADITIONAL, status); /* Determine if we are printing a calendar for one month or for a year */ /* Print an entire year */ if(month == -1 && year != -1) { /* Set the year */ ucal_set(c, UCAL_YEAR, year); /* Determine the first day of the week */ fdow = ucal_getAttribute(c, UCAL_FIRST_DAY_OF_WEEK); /* Print the calendar for the year */ print_year(c, days, months, useLongNames, fdow, status); } /* Print only one month */ else { /* Set the month and the year, if specified */ if(month != -1) ucal_set(c, UCAL_MONTH, month); if(year != -1) ucal_set(c, UCAL_YEAR, year); /* Determine the first day of the week */ fdow = ucal_getAttribute(c, UCAL_FIRST_DAY_OF_WEEK); /* Print the calendar for the month */ print_month(c, days, useLongNames, fdow, status); } /* Clean up */ ucal_close(c); }
int main(void) { int day_amount[MONTH_AMOUNT] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char month_name[][MONTH_AMOUNT] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; int i, sum_day = 1; for (i = 0; i < MONTH_AMOUNT; i++) { printf(" ============%s============\n", month_name[i]); print_month((sum_day-1)%7, day_amount[i]); printf("\n"); sum_day += day_amount[i]; } return 0; }