[Remind-Fans] next 7 days -c+1

hymie at lactose.homelinux.net hymie at lactose.homelinux.net
Fri May 9 11:28:29 EDT 2014


hymie at lactose.homelinux.net writes:
>"brock at quantifier.org" writes:
>>Hello.  I've seen similar questions, but not this one:
>>
>>rem -c+1 gives me a calendar view of this whole week, Sun-Sat.
>>
>>I'd like to be able to show 7 days, from today until next week, or 
>>even from yesterday until 7 days after that.
>
>I cannot find any option to specify first-day-of-the-week other than
>Sunday or Monday.

So I must be bored.  I have a patch that allows you to specify (by
number) which day you want to start on.  Unfortunately, option processing
is done before any calendaring is done, so I don't have a good way
to automagically determine "today" and adjust the calendar accordingly.

But if you know it's Friday, then

$ rem -c+1 -m5

+----------+----------+----------+----------+----------+----------+----------+
|  Friday  | Saturday |  Sunday  |  Monday  | Tuesday  |Wednesday | Thursday |
+----------+----------+----------+----------+----------+----------+----------+
|9 May ****|10 May    |11 May    |12 May    |13 May    |14 May    |15 May    |
|          |          |          |          |          |          |          |
|payday    |          |douglas   |          |          |wife      |          |
|          |          |adams died|          |          |payday    |          |
|billy joel|          |2001      |          |          |          |          |
|born 1949 |          |          |          |          |          |          |
+----------+----------+----------+----------+----------+----------+----------+

This patch does not affect rem2ps because it looks more complicated.

*** init.c.orig	2014-05-09 10:58:34.000000000 -0400
--- init.c	2014-05-09 11:19:42.000000000 -0400
***************
*** 66,72 ****
   *             by non-root, changes environment but not effective uid.
   *  -kcmd    = Run 'cmd' for MSG-type reminders instead of printing to stdout
   *  -iVAR=EXPR = Initialize and preserve VAR.
!  *  -m       = Start calendar with Monday instead of Sunday.
   *  -j[n]    = Purge all junk from reminder files (n = INCLUDE depth)
   *  A minus sign alone indicates to take input from stdin
   *
--- 66,73 ----
   *             by non-root, changes environment but not effective uid.
   *  -kcmd    = Run 'cmd' for MSG-type reminders instead of printing to stdout
   *  -iVAR=EXPR = Initialize and preserve VAR.
!  *  -m[n]    = Start calendar with Monday (or n days after Sunday)
!  *             instead of Sunday.
   *  -j[n]    = Purge all junk from reminder files (n = INCLUDE depth)
   *  A minus sign alone indicates to take input from stdin
   *
***************
*** 233,238 ****
--- 234,243 ----
  	    case 'm':
  	    case 'M':
  		MondayFirst = 1;
+       if (*arg)
+       {
+         PARSENUM(MondayFirst,arg);
+       }
  		break;
  
  	    case 'o':
***************
*** 630,636 ****
      fprintf(ErrFp, " -kcmd  Run `cmd' for MSG-type reminders\n");
      fprintf(ErrFp, " -g[dddd] Sort reminders by date, time, priority, and 'timedness'\n");
      fprintf(ErrFp, " -ivar=val Initialize var to val and preserve var\n");
!     fprintf(ErrFp, " -m     Start calendar with Monday rather than Sunday\n");
      fprintf(ErrFp, " -y     Synthesize tags for tagless reminders\n");
      fprintf(ErrFp, " -j[n]  Run in 'purge' mode.  [n = INCLUDE depth]\n");
      exit(1);
--- 635,641 ----
      fprintf(ErrFp, " -kcmd  Run `cmd' for MSG-type reminders\n");
      fprintf(ErrFp, " -g[dddd] Sort reminders by date, time, priority, and 'timedness'\n");
      fprintf(ErrFp, " -ivar=val Initialize var to val and preserve var\n");
!     fprintf(ErrFp, " -m[n]  Start calendar with Monday (or n days after Sunday)\n");
      fprintf(ErrFp, " -y     Synthesize tags for tagless reminders\n");
      fprintf(ErrFp, " -j[n]  Run in 'purge' mode.  [n = INCLUDE depth]\n");
      exit(1);
*** calendar.c.orig	2014-05-09 10:58:26.000000000 -0400
--- calendar.c	2014-05-09 11:18:00.000000000 -0400
***************
*** 255,262 ****
  	    DoCalendarOneMonth();
  	return;
      } else {
! 	if (MondayFirst) JulianToday -= (JulianToday%7);
! 	else             JulianToday -= ((JulianToday+1)%7);
  
  	if (!DoSimpleCalendar) {
    	    WriteWeekHeaderLine();
--- 255,261 ----
  	    DoCalendarOneMonth();
  	return;
      } else {
!             JulianToday -= ((JulianToday + (1-MondayFirst))%7);
  
  	if (!DoSimpleCalendar) {
    	    WriteWeekHeaderLine();
***************
*** 294,301 ****
  
  /* If it's "Simple Calendar" format, do it simply... */
      if (DoSimpleCalendar) {
! 	if (MondayFirst) wd = JulianToday % 7;
! 	else             wd = (JulianToday + 1) % 7;
  	for (i=0; i<7; i++) {
  	    WriteSimpleEntries(i, OrigJul+i-wd);
  	}
--- 293,299 ----
  
  /* If it's "Simple Calendar" format, do it simply... */
      if (DoSimpleCalendar) {
!       wd = (JulianToday + (1-MondayFirst)) % 7;
  	for (i=0; i<7; i++) {
  	    WriteSimpleEntries(i, OrigJul+i-wd);
  	}
***************
*** 419,426 ****
  
  /* Get the date of the first day */
      FromJulian(JulianToday, &y, &m, &d);
!     if (!MondayFirst) wd = (JulianToday + 1) % 7;
!     else		     wd = JulianToday % 7;
  
  /* Fill in the column entries */
      for (i=wd; i<7; i++) {
--- 417,423 ----
  
  /* Get the date of the first day */
      FromJulian(JulianToday, &y, &m, &d);
!     wd = (JulianToday + (1 - MondayFirst)) % 7;
  
  /* Fill in the column entries */
      for (i=wd; i<7; i++) {
***************
*** 1354,1363 ****
      DRAW(tb);
      goff();
      for (i=0; i<7; i++) {
! 	if (!MondayFirst)
! 	    PrintCentered(DayName[(i+6)%7], ColSpaces, " ");
! 	else
! 	    PrintCentered(DayName[i%7], ColSpaces, " ");
  	gon();
  	DRAW(tb);
  	goff();
--- 1351,1357 ----
      DRAW(tb);
      goff();
      for (i=0; i<7; i++) {
!       PrintCentered(DayName[(i+6+MondayFirst)%7], ColSpaces, " ");
  	gon();
  	DRAW(tb);
  	goff();

--hymie!    http://lactose.homelinux.net/~hymie    hymie at lactose.homelinux.net


More information about the Remind-fans mailing list