Previous: Resource file, Up: Fixed Dates


5.2 Resource file examples

Here are some examples of problem oriented resource files which might be useful to get a deeper impression about the attributes of Gcal's fixed date feature.

Let us begin with a common example, the resource file common.rc:

     

$ cat common.rc -| ; common.rc, a common example of a resource file. -| ; -| 19940715 Local time: %t --> Dentist at 10:00 -| 00000921 My %B1962 birthday%i1952#2062 -| 0000093 Gregorian~Reformation\~is %y1752 years ago -| 0000Sep03 Gregorian~Reformation\~is %y1752 years ago -| 0 Every day in every month in every year -| 0000 Every day in every month in every year -| 00000000 Every day in every month in every year -| 199400fri Every Friday in 1994 -| 000007mo3 Every third Monday~in July every year less 1980%i#1979 -| 0000@e-10 Easter Sunday-10 days every year -| 0@e-10 Easter Sunday-10 days every year -| 0000@e+10 Easter Sunday+10 days every year -| a=1127 -| 0@a+20 20 days after date of date variable `a' -| a=*W10FR -| 0@a-1 The Thursday of the 10th week every year -| 0@a The Friday of the 10th week every year -| 0@a1 The Saturday of the 10th week every year -| 1995*d10 The 10th absolute day in 1995 -| 1995*d99tue The last Tuesday in 1995 -| 0*w99su The Sunday of the last week every year -| ; -| ; Next entry is respected by ALL fixed date period modifiers. -| ; -| 1994*d1sun#99SUN.7 Each Sunday in 1994 -| ; -| ; Day of Prayer & Repentance is Wednesday before the Sunday, -| ; which is before the 1st Advent's Sunday. -| ; -| a=1225 -| a=a-5sun -| 0@a-4 Day of Prayer & Repentance -| ; or -| 0@a-1wed Day of Prayer & Repentance

And here is a resource file by the name of demo-1.rc, used to detect all Fridays the 13th of a year:

     

$ cat demo-1.rc -| ; demo-1.rc -| ; -| $a=Friday the 13th%i0000 -| $b=#0000 -| $c=fri2 -| $d=fri3 -| 00000113 $a01$c$b01$c -| 00000113 $a01$d$b01$d -| 00000213 $a02$c$b02$c -| 00000213 $a02$d$b02$d -| 00000313 $a03$c$b03$c -| 00000313 $a03$d$b03$d -| 00000413 $a04$c$b04$c -| 00000413 $a04$d$b04$d -| 00000513 $a05$c$b05$c -| 00000513 $a05$d$b05$d -| 00000613 $a06$c$b06$c -| 00000613 $a06$d$b06$d -| 00000713 $a07$c$b07$c -| 00000713 $a07$d$b07$d -| 00000813 $a08$c$b08$c -| 00000813 $a08$d$b08$d -| 00000913 $a09$c$b09$c -| 00000913 $a09$d$b09$d -| 00001013 $a10$c$b10$c -| 00001013 $a10$d$b10$d -| 00001113 $a11$c$b11$c -| 00001113 $a11$d$b11$d -| 00001213 $a12$c$b12$c -| 00001213 $a12$d$b12$d

The result for the years 1996...2002 is as follows:

     

$ gcal -H no -u -x -f ./demo-1.rc 1996+2002 -| -| Fri, Sep 13th 1996: Friday the 13th -| Fri, Dec 13th 1996: Friday the 13th -| -| Fri, Jun 13th 1997: Friday the 13th -| -| Fri, Feb 13th 1998: Friday the 13th -| Fri, Mar 13th 1998: Friday the 13th -| Fri, Nov 13th 1998: Friday the 13th -| -| Fri, Aug 13th 1999: Friday the 13th -| -| Fri, Oct 13th 2000: Friday the 13th -| -| Fri, Apr 13th 2001: Friday the 13th -| Fri, Jul 13th 2001: Friday the 13th -| -| Fri, Sep 13th 2002: Friday the 13th -| Fri, Dec 13th 2002: Friday the 13th

Or a bit shorter version of the resource file demo-1.rc by the name of demo-2.rc, likewise used to detect all Fridays the 13th of a year, and that by using the fact, that a Friday the 13th only occurs if the first day of a month is a Sunday:

     

$ cat demo-2.rc -| ; demo-2.rc -| ; -| $a=%n+12 is a Friday%i0000 -| $b=#0000 -| $c=sun1 -| 00000101 $a01$c$b01$c -| 00000201 $a02$c$b02$c -| 00000301 $a03$c$b03$c -| 00000401 $a04$c$b04$c -| 00000501 $a05$c$b05$c -| 00000601 $a06$c$b06$c -| 00000701 $a07$c$b07$c -| 00000801 $a08$c$b08$c -| 00000901 $a09$c$b09$c -| 00001001 $a10$c$b10$c -| 00001101 $a11$c$b11$c -| 00001201 $a12$c$b12$c

The result for the years 1996...2002 is as follows:

     

$ gcal -H no -u -x -f ./demo-2.rc 1996+2002 -| -| Sun, Sep 1st 1996: 13-Sep-1996 is a Friday -| Sun, Dec 1st 1996: 13-Dec-1996 is a Friday -| -| Sun, Jun 1st 1997: 13-Jun-1997 is a Friday -| -| Sun, Feb 1st 1998: 13-Feb-1998 is a Friday -| Sun, Mar 1st 1998: 13-Mar-1998 is a Friday -| Sun, Nov 1st 1998: 13-Nov-1998 is a Friday -| -| Sun, Aug 1st 1999: 13-Aug-1999 is a Friday -| -| Sun, Oct 1st 2000: 13-Oct-2000 is a Friday -| -| Sun, Apr 1st 2001: 13-Apr-2001 is a Friday -| Sun, Jul 1st 2001: 13-Jul-2001 is a Friday -| -| Sun, Sep 1st 2002: 13-Sep-2002 is a Friday -| Sun, Dec 1st 2002: 13-Dec-2002 is a Friday

Of course, preceding textual expense for the purpose of detecting all Fridays the 13th of a year can be dramatically reduced by simply using of

     0*d1fri#99fri.7 Friday the 13th%i00000013#00000013

in the resource file demo-1.rc, respectively,

     0*d1sun#99sun.7 %n+12 is a Friday%i00000001#00000001

in the demo-2.rc resource file.

On the one hand, preceding one-liners reduce the coding expense quite considerably —from 28 respectively 15 lines to 1 line in each case—, but on the other hand, this partly increases the checking expense of these one-liners considerably and result in a longer program run-time therefore. Both one-liners produce about 52 internal productions respectively effective fixed date entries of themselves for each year checked by Gcal, at which the demo-1.rc and demo-2.rc resource files cause 24 respectively 12 effective fixed date entries only.

And here is a resource file by the name of demo-3.rc, used to detect all working-days of any month:

     

$ cat demo-3.rc -| ; demo-3.rc -| ; -| $a=%VWork day -| $c=%i#0000$b99 -| a=$bmon1 -| 0@a#+4 $a -| a=$btue1 -| 0@a#+3 $a -| a=$bwed1 -| 0@a#+2 $a -| a=$bthu1 -| 0@a#+1 $a -| a=$bfri1 -| 0@a $a -| a=$bmon2 -| 0@a#+4 $a -| a=$bmon3 -| 0@a#+4 $a -| a=$bmon4 -| 0@a#+4 $a$c -| a=$bmon9 -| 0@a#+4 $a$c

Respectively a bit shorter version of the resource file demo-3.rc:

     ; demo-3.rc
     ;
     $a=%VWork day
     $c=%i#0000$b99
     0000$bmon1:5 $a
     0000$btue1:4 $a
     0000$bwed1:3 $a
     0000$bthu1:2 $a
     0000$bfri1:1 $a
     0000$bmon2:5 $a
     0000$bmon3:5 $a
     0000$bmon4:5 $a$c
     0000$bmon9:5 $a$c

And a resource file by the name of include.rc exists which is only used to include one given resource file:

     

$ cat include.rc -| #include "$f"

Then the result for the month August 1996 is as follows:

     

$ gcal -H no -u -x -r '$b=08:$f=demo-3.rc' -f ./include.rc Aug 1996 -| -| Thu, Aug 1st 1996: Work day -| Fri, Aug 2nd 1996: Work day -| Mon, Aug 5th 1996: Work day -| Tue, Aug 6th 1996: Work day -| Wed, Aug 7th 1996: Work day -| Thu, Aug 8th 1996: Work day -| Fri, Aug 9th 1996: Work day -| Mon, Aug 12th 1996: Work day -| Tue, Aug 13th 1996: Work day -| Wed, Aug 14th 1996: Work day -| Thu, Aug 15th 1996: Work day -| Fri, Aug 16th 1996: Work day -| Mon, Aug 19th 1996: Work day -| Tue, Aug 20th 1996: Work day -| Wed, Aug 21st 1996: Work day -| Thu, Aug 22nd 1996: Work day -| Fri, Aug 23rd 1996: Work day -| Mon, Aug 26th 1996: Work day -| Tue, Aug 27th 1996: Work day -| Wed, Aug 28th 1996: Work day -| Thu, Aug 29th 1996: Work day -| Fri, Aug 30th 1996: Work day

And of course, the preceding textual expense for the purpose of detecting all work days of any month can be dramatically reduced by simply using of

     00000001#0099 %V%rWork day

in the resource file demo-3.rc.

And next the resource file by the name of sun-1.rc which detects the actual local time, the approximate time of sunrise and sunset, day and night length of two geographic locations:

     

$ cat sun-1.rc -| ; sun-1.rc, comparison of sunrise / sunset, day length and night -| ; length of two locations, namely: Muenster.DE / Bangkok.TH -| ; All references are based on Muenster.DE ! -| ; -| ; Common definitions -| $p=0*d1#999 -| $v=%2%4 for that places local time -| $z=actual local time in -| ; Definitions for winter time -| $a=%e#1980 %e0@a#0@b-1 -| $x=Sun:~%o$c,$w rise, %s$c,$w set, %u$c,$w day, %z$c,$w night~$l -| ; Winter time in Germany == CEWT/GMT-1 (+60 minutes) -| $w=+60 -| ; Starting date of winter time in Germany -| b=10sun9 -| ; Definitions for summer time (daylight-saving time) -| $b=%e#1980 %i0@a#0@b-1 -| $y=Sun:~%o$c,$s rise, %s$c,$s set, %u$c,$s day, %z$c,$s night~$l -| ; Summer time in Germany == CEST/GMT-2 (+120 minutes) -| $s=+120 -| ; Starting date of summer time in Germany -| a=03sun9 -| ; Geographic co-ordinate and name of the location Muenster, Germany -| $c=+5158+00738+61 -| $l=%1Muenster -| ; Muenster's local time sunrise etc. for that places local time -| $p $a $x$v -| $p $b $y$v -| ; Muenster's actual local time -| 0 $a %1%@$w %2 $z $l -| 0 $b %1%@$s %2 $z $l -| ; Geographic co-ordinate and name of the location Bangkok, Thailand -| $c=+1345+10031+10 -| $l=%3Bangkok%4-time converted to $l's%2 local time -| ; Bangkok's sunrise etc. based on Muenster's local time -| $p $a $x -| $p $b $y -| ; Bangkok's local time == WAST/GMT-7 (+420 minutes) -| $t=+420 -| $w=$t -| ; Bangkok's actual local time -| $l=%3Bangkok -| 0 $a %3%@$t %4 $z $l -| 0 $b %3%@$t %4 $z $l -| ; Bangkok's sunrise etc. for that places local time -| $l=$l$v -| $p $x

The result for the 12th September 1999 is as follows:

     

$ gcal -fsun-1.rc -Ux -Hno -| -| 18:53/12-Sep-1999 actual local time in Muenster -| 23:53/12-Sep-1999 actual local time in Bangkok -| Sun: -| 01:06rise, 13:22set, 12h16'day, 11h44'night -| Bangkok-time converted to Muenster's local time -| Sun: -| 06:06rise, 18:22set, 12h16'day, 11h44'night -| Bangkok for that places local time -| Sun: -| 06:56rise, 19:54set, 12h58'day, 11h02'night -| Muenster for that places local time

The next example is the resource file redir-1.rc which demonstrates the use of the shell command %![argument] special text:

     

$ cat redir-1.rc -| ; redir.rc, run shell command $c and redirect it to $f -| ; -| $p=0*d1#999 -| $c=$p %!$c -| $g=|txt2gcal - $p -| ; -| $c $g>$f

The result of succeeding call of Gcal, to which you can also add the --debug=all option for a better understanding of the execution methods, is as follows:

     

$ gcal --exe -QUx -f./redir-1.rc+XX -r'$f=XX:$c=echo $f' -#'0 %!rm $f' -| XX

And finally a resource file by the name of swtim-1.rc which produces fixed date messages reminding Daylight Saving that are valid since 1981 for the Federal Republic of Germany1.

     

$ cat swtim-1.rc -| ; swtim-1.rc, daylight-saving time BRD -| ; -| $a=daylight-saving time starts Sunday -| ; -| a=03sun9 -| 0@a-2#+2 Summer $a~+1 hrs. (02:00 --> 03:00 h.)%i1981 -| ; -| a=09sun9 -| 0@a-2#+2 Winter $a~-1 hrs. (03:00 --> 02:00 h.)%i1981#1995 -| ; -| a=10sun9 -| 0@a-2#+2 Winter $a~-1 hrs. (03:00 --> 02:00 h.)%i1996

The result for the year 1998 is as follows:

     

$ gcal %1998 -Hno -xy -f ./swtim-1.rc -| -| Fri, Mar 27th 1998: Summer daylight-saving time starts Sunday -| +1 hrs. (02:00 --> 03:00 h.) -| Sat, Mar 28th 1998: Summer daylight-saving time starts Sunday -| +1 hrs. (02:00 --> 03:00 h.) -| Sun, Mar 29th 1998: Summer daylight-saving time starts Sunday -| +1 hrs. (02:00 --> 03:00 h.) -| Mon, Mar 30th 1998: Summer daylight-saving time starts Sunday -| +1 hrs. (02:00 --> 03:00 h.) -| Tue, Mar 31st 1998: Summer daylight-saving time starts Sunday -| +1 hrs. (02:00 --> 03:00 h.) -| Fri, Oct 23rd 1998: Winter daylight-saving time starts Sunday -| -1 hrs. (03:00 --> 02:00 h.) -| Sat, Oct 24th 1998: Winter daylight-saving time starts Sunday -| -1 hrs. (03:00 --> 02:00 h.) -| Sun, Oct 25th 1998: Winter daylight-saving time starts Sunday -| -1 hrs. (03:00 --> 02:00 h.) -| Mon, Oct 26th 1998: Winter daylight-saving time starts Sunday -| -1 hrs. (03:00 --> 02:00 h.) -| Tue, Oct 27th 1998: Winter daylight-saving time starts Sunday -| -1 hrs. (03:00 --> 02:00 h.)


Footnotes

[1] Two days before adaptation till two days after adaptation.