summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/calendar.c237
1 files changed, 108 insertions, 129 deletions
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index cc4e5f9eb2..18706c14f6 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -279,7 +279,7 @@ static bool been_in_usb_mode = false;
279static int is_leap_year(int yr) 279static int is_leap_year(int yr)
280{ 280{
281 return ((yr) <= 1752 ? !((yr) % 4) : \ 281 return ((yr) <= 1752 ? !((yr) % 4) : \
282 (!((yr) % 4) && ((yr) % 100)) || !((yr) % 400)) ? 1:0 ; 282 (!((yr) % 4) && ((yr) % 100)) || !((yr) % 400)) ? 1:0 ;
283} 283}
284 284
285/* searches the weekday of the first day in month, 285/* searches the weekday of the first day in month,
@@ -287,28 +287,25 @@ static int is_leap_year(int yr)
287static int calc_weekday( struct shown *shown ) 287static int calc_weekday( struct shown *shown )
288{ 288{
289 return ( shown->wday + 36 - shown->mday ) % 7 ; 289 return ( shown->wday + 36 - shown->mday ) % 7 ;
290
291} 290}
292 291
293static void calendar_init(struct shown *shown) 292static void calendar_init(struct shown *shown)
294{ 293{
295 int w,h; 294 int w, h;
296#if CONFIG_RTC 295#if CONFIG_RTC
297 struct tm *tm; 296 struct tm *tm;
298#endif 297#endif
299 rb->lcd_getstringsize("A",&w,&h); 298 rb->lcd_getstringsize("A", &w, &h);
300 if ( ((w * 14) > LCD_WIDTH) || ((h * 7) > LCD_HEIGHT) ) 299 if ( ((w * 14) > LCD_WIDTH) || ((h * 7) > LCD_HEIGHT) )
301 { 300 {
302 rb->lcd_setfont(FONT_SYSFIXED);
303 use_system_font = true; 301 use_system_font = true;
304 } 302 }
305 rb->lcd_clear_display();
306#if CONFIG_RTC 303#if CONFIG_RTC
307 tm = rb->get_time(); 304 tm = rb->get_time();
308 shown->mday = tm->tm_mday; 305 shown->mday = tm->tm_mday;
309 shown->mon = tm->tm_mon +1; 306 shown->mon = tm->tm_mon + 1;
310 shown->year = 2000+tm->tm_year%100; 307 shown->year = 2000 + (tm->tm_year%100);
311 shown->wday = tm->tm_wday-1; 308 shown->wday = tm->tm_wday - 1;
312#endif 309#endif
313 shown->firstday = calc_weekday(shown); 310 shown->firstday = calc_weekday(shown);
314 leap_year = is_leap_year(shown->year); 311 leap_year = is_leap_year(shown->year);
@@ -316,47 +313,47 @@ static void calendar_init(struct shown *shown)
316 313
317static void draw_headers(void) 314static void draw_headers(void)
318{ 315{
319 int i,w,h; 316 int i, w, h;
320 int x = X_OFFSET; 317 int x = X_OFFSET;
321 const char **dayname = (const char**)&dayname_long; 318 const char **dayname = dayname_long;
322 319
323 for (i = 0; i < 7; i++) 320 for (i = 0; i < 7; i++)
324 { 321 {
325 rb->lcd_getstringsize(dayname[i],&w,&h); 322 rb->lcd_getstringsize(dayname[i], &w, &h);
326 if (w > CELL_WIDTH) 323 if (w > CELL_WIDTH)
327 { 324 {
328 dayname = (const char**)&dayname_short; 325 dayname = dayname_short;
329 break; 326 break;
330 } 327 }
331 } 328 }
332 329
333 rb->lcd_getstringsize("A",&w,&h); 330 rb->lcd_getstringsize("A", &w, &h);
334 for (i = 0; i < 7; i++) 331 for (i = 0; i < 7; i++)
335 { 332 {
336 rb->lcd_putsxy(x, 0 , dayname[i]); 333 rb->lcd_putsxy(x, 0, dayname[i]);
337 x += CELL_WIDTH; 334 x += CELL_WIDTH;
338 } 335 }
339 rb->lcd_hline(0, LCD_WIDTH-1 ,h); 336 rb->lcd_hline(0, LCD_WIDTH-1, h);
340} 337}
341 338
342static bool day_has_memo[32]; 339static bool day_has_memo[32];
343static bool wday_has_memo[7]; 340static bool wday_has_memo[7];
344static void draw_calendar(struct shown *shown) 341static void draw_calendar(struct shown *shown)
345{ 342{
346 int w,h; 343 int w, h;
347 int x,y,pos,days_per_month,j; 344 int x, y, pos, days_per_month, j;
348 char buffer[9]; 345 char buffer[12];
349 const char *monthname[] = { 346 const char *monthname[] = {
350 "Jan", "Feb", "Mar", "Apr", "May", "Jun", 347 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
351 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 348 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
352 }; 349 };
353 if(use_system_font) 350 if(use_system_font)
351 {
354 rb->lcd_setfont(FONT_SYSFIXED); 352 rb->lcd_setfont(FONT_SYSFIXED);
355 rb->lcd_getstringsize("A",&w,&h); 353 }
354 rb->lcd_getstringsize("A", &w, &h);
356 rb->lcd_clear_display(); 355 rb->lcd_clear_display();
357 draw_headers(); 356 draw_headers();
358 if (shown->firstday > 6)
359 shown->firstday -= 7;
360 pos = shown->firstday; 357 pos = shown->firstday;
361 days_per_month = days_in_month[leap_year][shown->mon]; 358 days_per_month = days_in_month[leap_year][shown->mon];
362 x = X_OFFSET + (pos * CELL_WIDTH); 359 x = X_OFFSET + (pos * CELL_WIDTH);
@@ -364,9 +361,9 @@ static void draw_calendar(struct shown *shown)
364 for (j = 1; j <= days_per_month; j++) 361 for (j = 1; j <= days_per_month; j++)
365 { 362 {
366 if ( (day_has_memo[j]) || (wday_has_memo[pos]) ) 363 if ( (day_has_memo[j]) || (wday_has_memo[pos]) )
367 rb->snprintf(buffer,4,"%02d.", j); 364 rb->snprintf(buffer, 4, "%02d.", j);
368 else 365 else
369 rb->snprintf(buffer,4,"%02d", j); 366 rb->snprintf(buffer, 4, "%02d", j);
370 if (shown->mday == j) 367 if (shown->mday == j)
371 { 368 {
372 rb->lcd_set_drawmode(DRMODE_SOLID); 369 rb->lcd_set_drawmode(DRMODE_SOLID);
@@ -388,12 +385,13 @@ static void draw_calendar(struct shown *shown)
388 y += CELL_HEIGHT; 385 y += CELL_HEIGHT;
389 } 386 }
390 } 387 }
391 rb->lcd_set_drawmode(DRMODE_SOLID);
392 rb->lcd_vline(LCD_WIDTH-w*8-10,LCD_HEIGHT-h-3,LCD_HEIGHT-1);
393 rb->lcd_hline(LCD_WIDTH-w*8-10,LCD_WIDTH-1,LCD_HEIGHT-h-3);
394 rb->snprintf(buffer,9,"%s %04d",monthname[shown->mon-1],shown->year);
395 rb->lcd_putsxy(LCD_WIDTH-w*8-8,LCD_HEIGHT-h-1,buffer);
396 shown->lastday = pos; 388 shown->lastday = pos;
389 rb->lcd_set_drawmode(DRMODE_SOLID);
390 rb->lcd_vline(LCD_WIDTH-w*8-10, LCD_HEIGHT-h-3, LCD_HEIGHT-1);
391 rb->lcd_hline(LCD_WIDTH-w*8-10, LCD_WIDTH-1, LCD_HEIGHT-h-3);
392 rb->snprintf(buffer, sizeof(buffer), "%s %04d",
393 monthname[shown->mon-1], shown->year);
394 rb->lcd_putsxy(LCD_WIDTH-w*8-8, LCD_HEIGHT-h-1, buffer);
397 rb->lcd_update(); 395 rb->lcd_update();
398} 396}
399 397
@@ -435,54 +433,38 @@ static void load_memo(struct shown *shown)
435 while (!exit) 433 while (!exit)
436 { 434 {
437 bool load_to_memory; 435 bool load_to_memory;
438 rb->memset(&memos[memos_in_memory].message, 0, MAX_CHAR_MEMO_LEN); 436 struct memo *memo = &memos[memos_in_memory];
439 memos[memos_in_memory].file_pointer_start = 437 rb->memset(memo, 0, sizeof(*memo));
440 rb->lseek(fp, 0, SEEK_CUR); 438 memo->file_pointer_start = rb->lseek(fp, 0, SEEK_CUR);
441 if (rb->read(fp, temp_memo2, 2) == 2) 439 if (rb->read(fp, temp_memo2, 2) == 2)
442 memos[memos_in_memory].day = rb->atoi(&temp_memo2[0]); 440 memo->day = rb->atoi(temp_memo2);
443 else
444 memos[memos_in_memory].day = 0;
445 if (rb->read(fp, temp_memo2, 2) == 2) 441 if (rb->read(fp, temp_memo2, 2) == 2)
446 memos[memos_in_memory].month = rb->atoi(&temp_memo2[0]); 442 memo->month = rb->atoi(temp_memo2);
447 else
448 memos[memos_in_memory].month = 0;
449 if (rb->read(fp, temp_memo4, 4) == 4) 443 if (rb->read(fp, temp_memo4, 4) == 4)
450 memos[memos_in_memory].year = rb->atoi(&temp_memo4[0]); 444 memo->year = rb->atoi(temp_memo4);
451 else
452 memos[memos_in_memory].year = 0;
453 /* as the year returned is sometimes yearmonth, ie if yr should =
454 2003, and month = 06, then it returns 200306 */
455 if (memos[memos_in_memory].year > (shown->year * 10))
456 memos[memos_in_memory].year = (memos[memos_in_memory].year -
457 memos[memos_in_memory].month) /
458 100;
459 if (rb->read(fp, temp_memo1, 1) == 1) 445 if (rb->read(fp, temp_memo1, 1) == 1)
460 memos[memos_in_memory].wday = rb->atoi(&temp_memo1[0]); 446 memo->wday = rb->atoi(temp_memo1);
461 else
462 memos[memos_in_memory].wday = 0;
463 if (rb->read(fp, temp_memo1, 1) == 1) 447 if (rb->read(fp, temp_memo1, 1) == 1)
464 memos[memos_in_memory].type = rb->atoi(&temp_memo1[0]); 448 memo->type = rb->atoi(temp_memo1);
465 else 449 load_to_memory = ((memo->type < 2) ||
466 memos[memos_in_memory].type = 0; 450 ((memo->type == 2) &&
467 load_to_memory = ((memos[memos_in_memory].type < 2) || 451 (memo->month == shown->mon)) ||
468 ((memos[memos_in_memory].type == 2) && 452 ((memo->type > 2) &&
469 (memos[memos_in_memory].month == shown->mon)) || 453 (memo->month == shown->mon) &&
470 ((memos[memos_in_memory].type > 2) && 454 (memo->year == shown->year)));
471 (memos[memos_in_memory].month == shown->mon) &&
472 (memos[memos_in_memory].year == shown->year)));
473 k = 0; 455 k = 0;
474 while (1) 456 while (1)
475 { 457 {
476 if (rb->read(fp, temp_memo1, 1) != 1) 458 if (rb->read(fp, temp_memo1, 1) != 1)
477 { 459 {
478 memos[memos_in_memory].day = 0; 460 memo->day = 0;
479 memos[memos_in_memory].month = 0; 461 memo->month = 0;
480 memos[memos_in_memory].file_pointer_start = 0; 462 memo->file_pointer_start = 0;
481 memos[memos_in_memory].file_pointer_end = 0; 463 memo->file_pointer_end = 0;
482 memos[memos_in_memory].year = 0; 464 memo->year = 0;
483 memos[memos_in_memory].type = 0; 465 memo->type = 0;
484 memos[memos_in_memory].wday = 0; 466 memo->wday = 0;
485 memos[memos_in_memory].message[0] = 0; 467 memo->message[0] = 0;
486 exit = true; 468 exit = true;
487 break; 469 break;
488 } 470 }
@@ -490,19 +472,17 @@ static void load_memo(struct shown *shown)
490 { 472 {
491 if (temp_memo1[0] == '\n') 473 if (temp_memo1[0] == '\n')
492 { 474 {
493 if (memos[memos_in_memory].type > 0) 475 if (memo->type > 0)
494 day_has_memo[memos[memos_in_memory].day] = 476 day_has_memo[memo->day] = true;
495 true;
496 else 477 else
497 wday_has_memo[memos[memos_in_memory].wday] = 478 wday_has_memo[memo->wday] = true;
498 true; 479 memo->file_pointer_end = rb->lseek(fp, 0, SEEK_CUR);
499 memos[memos_in_memory++].file_pointer_end = 480 memos_in_memory++;
500 rb->lseek(fp, 0, SEEK_CUR);
501 } 481 }
502 else if ( (temp_memo1[0] != '\r') && 482 else if ( (temp_memo1[0] != '\r') &&
503 (temp_memo1[0] != '\t') && 483 (temp_memo1[0] != '\t') &&
504 k < MAX_CHAR_MEMO_LEN-1 ) 484 k < MAX_CHAR_MEMO_LEN-1 )
505 memos[memos_in_memory].message[k++] = temp_memo1[0]; 485 memo->message[k++] = temp_memo1[0];
506 } 486 }
507 if (temp_memo1[0] == '\n') 487 if (temp_memo1[0] == '\n')
508 break; 488 break;
@@ -514,7 +494,7 @@ static void load_memo(struct shown *shown)
514 494
515static bool save_memo(int changed, bool new_mod, struct shown *shown) 495static bool save_memo(int changed, bool new_mod, struct shown *shown)
516{ 496{
517 int fp,fq; 497 int fp, fq;
518 /* use O_RDWR|O_CREAT so that file is created if it doesn't exist. */ 498 /* use O_RDWR|O_CREAT so that file is created if it doesn't exist. */
519 fp = rb->open(MEMO_FILE, O_RDWR|O_CREAT); 499 fp = rb->open(MEMO_FILE, O_RDWR|O_CREAT);
520 fq = rb->creat(TEMP_FILE); 500 fq = rb->creat(TEMP_FILE);
@@ -522,26 +502,23 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
522 { 502 {
523 int i; 503 int i;
524 char temp[MAX_CHAR_MEMO_LEN]; 504 char temp[MAX_CHAR_MEMO_LEN];
505 struct memo *memo = &memos[changed];
525 rb->lseek(fp, 0, SEEK_SET); 506 rb->lseek(fp, 0, SEEK_SET);
526 for (i = 0; i < memos[changed].file_pointer_start; i++) 507 for (i = 0; i < memo->file_pointer_start; i++)
527 { 508 {
528 rb->read(fp, temp, 1); 509 rb->read(fp, temp, 1);
529 rb->write(fq,temp,1); 510 rb->write(fq, temp, 1);
530 } 511 }
531 if (new_mod) 512 if (new_mod)
532 { 513 {
533 rb->fdprintf(fq, "%02d%02d%04d%01d%01d%s\n", 514 rb->fdprintf(fq, "%02d%02d%04d%01d%01d%s\n",
534 memos[changed].day, 515 memo->day, memo->month, memo->year, memo->wday,
535 memos[changed].month, 516 memo->type, memo->message);
536 memos[changed].year,
537 memos[changed].wday,
538 memos[changed].type,
539 memos[changed].message);
540 } 517 }
541 rb->lseek(fp, memos[changed].file_pointer_end, SEEK_SET); 518 rb->lseek(fp, memo->file_pointer_end, SEEK_SET);
542 while(rb->read(fp, temp, 1) == 1) 519 while(rb->read(fp, temp, 1) == 1)
543 { 520 {
544 rb->write(fq,temp,1); 521 rb->write(fq, temp, 1);
545 } 522 }
546 rb->close(fp); 523 rb->close(fp);
547 rb->close(fq); 524 rb->close(fq);
@@ -560,41 +537,39 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
560static void add_memo(struct shown *shown, int type) 537static void add_memo(struct shown *shown, int type)
561{ 538{
562 bool saved = false; 539 bool saved = false;
563 if (rb->kbd_input(memos[memos_in_memory].message, 540 struct memo *memo = &memos[memos_in_memory];
564 sizeof memos[memos_in_memory].message) == 0) 541 if (rb->kbd_input(memo->message, MAX_CHAR_MEMO_LEN) == 0)
565 { 542 {
566 if (rb->strlen(memos[memos_in_memory].message)) 543 if (memo->message[0])
567 { 544 {
568 memos[memos_in_memory].file_pointer_start = 0; 545 memo->file_pointer_start = 0;
569 memos[memos_in_memory].file_pointer_end = 0; 546 memo->file_pointer_end = 0;
570 memos[memos_in_memory].day = shown->mday; 547 memo->day = shown->mday;
571 memos[memos_in_memory].month = shown->mon; 548 memo->month = shown->mon;
572 memos[memos_in_memory].wday = shown->wday; 549 memo->wday = shown->wday;
573 memos[memos_in_memory].year = shown->year; 550 memo->year = shown->year;
574 memos[memos_in_memory].type = type; 551 memo->type = type;
575 if (save_memo(memos_in_memory,true,shown)) 552 if (save_memo(memos_in_memory, true, shown))
576 { 553 {
577 saved = true; 554 saved = true;
578 } 555 }
579 else 556 else
580 { 557 {
581 memos[memos_in_memory].file_pointer_start = 0; 558 memo->file_pointer_start = 0;
582 memos[memos_in_memory].file_pointer_end = 0; 559 memo->file_pointer_end = 0;
583 memos[memos_in_memory].day = 0; 560 memo->day = 0;
584 memos[memos_in_memory].month = 0; 561 memo->month = 0;
585 memos[memos_in_memory].year = 0; 562 memo->year = 0;
586 memos[memos_in_memory].type = 0; 563 memo->type = 0;
587 memos[memos_in_memory].wday = 0; 564 memo->wday = 0;
588 } 565 }
589 } 566 }
590 } 567 }
591 rb->lcd_clear_display(); 568 rb->lcd_clear_display();
592 if(use_system_font)
593 rb->lcd_setfont(FONT_SYSFIXED);
594 if (saved) 569 if (saved)
595 rb->splash(HZ/2,"Event added"); 570 rb->splash(HZ/2, "Event added");
596 else 571 else
597 rb->splash(HZ/2,"Event not added"); 572 rb->splash(HZ/2, "Event not added");
598} 573}
599 574
600static int edit_menu_cb(int action, const struct menu_item_ex *this_item) 575static int edit_menu_cb(int action, const struct menu_item_ex *this_item)
@@ -622,29 +597,29 @@ static bool edit_memo(int change, struct shown *shown)
622 switch (rb->do_menu(&edit_menu, &selected, NULL, false)) 597 switch (rb->do_menu(&edit_menu, &selected, NULL, false))
623 { 598 {
624 case 0: /* remove */ 599 case 0: /* remove */
625 save_memo(pointer_array[change],false,shown); 600 save_memo(change, false, shown);
626 return false; 601 return false;
627 602
628 case 1: /* edit */ 603 case 1: /* edit */
629 if(rb->kbd_input(memos[pointer_array[change]].message, 604 if(rb->kbd_input(memos[change].message,
630 sizeof memos[pointer_array[change]].message) == 0) 605 MAX_CHAR_MEMO_LEN) == 0)
631 save_memo(pointer_array[change],true,shown); 606 save_memo(change, true, shown);
632 return false; 607 return false;
633 608
634 case 2: /* weekly */ 609 case 2: /* weekly */
635 add_memo(shown,0); 610 add_memo(shown, 0);
636 return false; 611 return false;
637 612
638 case 3: /* monthly */ 613 case 3: /* monthly */
639 add_memo(shown,1); 614 add_memo(shown, 1);
640 return false; 615 return false;
641 616
642 case 4: /* yearly */ 617 case 4: /* yearly */
643 add_memo(shown,2); 618 add_memo(shown, 2);
644 return false; 619 return false;
645 620
646 case 5: /* one off */ 621 case 5: /* one off */
647 add_memo(shown,3); 622 add_memo(shown, 3);
648 return false; 623 return false;
649 624
650 case 6: /* playback control */ 625 case 6: /* playback control */
@@ -666,17 +641,17 @@ static const char* get_event_text(int selected, void *data,
666 char *buffer, size_t buffer_len) 641 char *buffer, size_t buffer_len)
667{ 642{
668 struct shown *shown = (struct shown *) data; 643 struct shown *shown = (struct shown *) data;
644 struct memo *memo;
669 if (selected < 0 || memos_in_shown_memory <= selected) 645 if (selected < 0 || memos_in_shown_memory <= selected)
670 { 646 {
671 return NULL; 647 return NULL;
672 } 648 }
673 if (memos[pointer_array[selected]].type == 2) 649 memo = &memos[pointer_array[selected]];
650 if (memo->type == 2)
674 rb->snprintf(buffer, buffer_len, "%s (%d yrs)", 651 rb->snprintf(buffer, buffer_len, "%s (%d yrs)",
675 memos[pointer_array[selected]].message, 652 memo->message, shown->year - memo->year);
676 shown->year - memos[pointer_array[selected]].year);
677 else 653 else
678 rb->snprintf(buffer, buffer_len, "%s", 654 rb->snprintf(buffer, buffer_len, "%s", memo->message);
679 memos[pointer_array[selected]].message);
680 return buffer; 655 return buffer;
681} 656}
682 657
@@ -694,14 +669,14 @@ static bool view_events(int selected, struct shown *shown)
694 669
695 while (!exit) 670 while (!exit)
696 { 671 {
697 button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 672 button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK);
698 rb->gui_synclist_do_button(&gui_memos,&button,LIST_WRAP_UNLESS_HELD); 673 rb->gui_synclist_do_button(&gui_memos, &button, LIST_WRAP_UNLESS_HELD);
699 674
700 switch (button) 675 switch (button)
701 { 676 {
702 case ACTION_STD_OK: 677 case ACTION_STD_OK:
703 selected = rb->gui_synclist_get_sel_pos(&gui_memos); 678 selected = rb->gui_synclist_get_sel_pos(&gui_memos);
704 return edit_memo(selected, shown); 679 return edit_memo(pointer_array[selected], shown);
705 break; 680 break;
706 681
707 case ACTION_STD_CANCEL: 682 case ACTION_STD_CANCEL:
@@ -721,13 +696,15 @@ static bool view_events(int selected, struct shown *shown)
721static void update_memos_shown(struct shown *shown) 696static void update_memos_shown(struct shown *shown)
722{ 697{
723 int i; 698 int i;
699 struct memo *memo;
724 memos_in_shown_memory = 0; 700 memos_in_shown_memory = 0;
725 for (i = 0; i < memos_in_memory; i++) 701 for (i = 0; i < memos_in_memory; i++)
726 if (((memos[i].type >= 1) && 702 {
727 (memos[i].day == shown->mday)) || 703 memo = &memos[i];
728 ((memos[i].type < 1) && 704 if (((memo->type >= 1) && (memo->day == shown->mday)) ||
729 (memos[i].wday == shown->wday))) 705 ((memo->type < 1) && (memo->wday == shown->wday)))
730 pointer_array[memos_in_shown_memory++] = i; 706 pointer_array[memos_in_shown_memory++] = i;
707 }
731} 708}
732 709
733static bool any_events(struct shown *shown, bool force) 710static bool any_events(struct shown *shown, bool force)
@@ -749,7 +726,7 @@ static void next_month(struct shown *shown, int step)
749 shown->mon++; 726 shown->mon++;
750 if (shown->mon > 12) 727 if (shown->mon > 12)
751 { 728 {
752 shown->mon=1; 729 shown->mon = 1;
753 shown->year++; 730 shown->year++;
754 leap_year = is_leap_year(shown->year); 731 leap_year = is_leap_year(shown->year);
755 } 732 }
@@ -776,6 +753,8 @@ static void prev_month(struct shown *shown, int step)
776 else if (shown->mday > days_in_month[leap_year][shown->mon]) 753 else if (shown->mday > days_in_month[leap_year][shown->mon])
777 shown->mday = days_in_month[leap_year][shown->mon]; 754 shown->mday = days_in_month[leap_year][shown->mon];
778 shown->firstday += 7 - (days_in_month[leap_year][shown->mon] % 7); 755 shown->firstday += 7 - (days_in_month[leap_year][shown->mon] % 7);
756 if (shown->firstday >= 7)
757 shown->firstday -= 7;
779 load_memo(shown); 758 load_memo(shown);
780 draw_calendar(shown); 759 draw_calendar(shown);
781} 760}