texlive[66949] Master: context-pocketdiary (26apr23)
commits+karl at tug.org
commits+karl at tug.org
Wed Apr 26 21:43:19 CEST 2023
Revision: 66949
http://tug.org/svn/texlive?view=revision&revision=66949
Author: karl
Date: 2023-04-26 21:43:18 +0200 (Wed, 26 Apr 2023)
Log Message:
-----------
context-pocketdiary (26apr23)
Modified Paths:
--------------
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/libexec/ctan2tds
trunk/Master/tlpkg/tlpsrc/collection-context.tlpsrc
Added Paths:
-----------
trunk/Master/texmf-dist/doc/context/third/pocketdiary/
trunk/Master/texmf-dist/doc/context/third/pocketdiary/LICENSE
trunk/Master/texmf-dist/doc/context/third/pocketdiary/README.md
trunk/Master/texmf-dist/doc/context/third/pocketdiary/VERSION
trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.pdf
trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.tex
trunk/Master/texmf-dist/tex/context/third/pocketdiary/
trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/
trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/moons-MP.mkiv
trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/t-moonphase.lua
trunk/Master/texmf-dist/tex/context/third/pocketdiary/PocketDiary.mkiv
trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/
trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/sun-MP.nkiv
trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/t-solar.lua
trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-calendar.lua
trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.lua
trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.mkiv
trunk/Master/tlpkg/tlpsrc/context-pocketdiary.tlpsrc
Added: trunk/Master/texmf-dist/doc/context/third/pocketdiary/LICENSE
===================================================================
--- trunk/Master/texmf-dist/doc/context/third/pocketdiary/LICENSE (rev 0)
+++ trunk/Master/texmf-dist/doc/context/third/pocketdiary/LICENSE 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,7 @@
+The module contains files which are under different licensing regimes:
+
+t-pocketdiary.tex : Public Domain
+t-pocketdiary.lua : Public Domain
+t-calendar.lua : Public Domain
+t-solar.lua : CCO "http://creativecommons.org/about/cc0"
+t-moonphase.lua : Public Domain
\ No newline at end of file
Added: trunk/Master/texmf-dist/doc/context/third/pocketdiary/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/context/third/pocketdiary/README.md (rev 0)
+++ trunk/Master/texmf-dist/doc/context/third/pocketdiary/README.md 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,12 @@
+## PocketDiary module
+
+# Description
+On the interenet there is a site where one can compose a so called PocketMod. This is based on 8 pages placed on a single sheet of paper, printed singlesided. The paper can then be folded into a booklet in such a way, that only printed pages are visible.
+
+The PocketDiary module implements the 8 pages on a A4 landscape sheet of paper. As the original there are different predefined possibilities to fill the 8 pages. First there are day, weekend, week, month and year tables. One can have not only the actual week, month, year, it is possible to have those a the following week. -- Beyond the calendars there are also a couple of templates for notes, todo, contacts and lost-return-to.
+
+Additionally the module can calculate sunrise and sunset times as well as calculate the moon-cylce.
+
+# Author
+W. Egger
+License: Everything is in the Public Domain except the algorithms contained in the solar data calculations (t-solar.lua) which license is: CCO "http://creativecommons.org/about/cc0"
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/doc/context/third/pocketdiary/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/context/third/pocketdiary/VERSION
===================================================================
--- trunk/Master/texmf-dist/doc/context/third/pocketdiary/VERSION (rev 0)
+++ trunk/Master/texmf-dist/doc/context/third/pocketdiary/VERSION 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1 @@
+2023.04.25
Added: trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.pdf 2023-04-26 19:41:30 UTC (rev 66948)
+++ trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.pdf 2023-04-26 19:43:18 UTC (rev 66949)
Property changes on: trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.tex 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,4 @@
+% The contents of the document t-pocketdiary-module-doc.pdf is generated
+% by the command. The source is the module file itself.
+
+mtxrun --script modules --process [PATH to]/t-pocketdiary.tex
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/doc/context/third/pocketdiary/t-pocketdiary-module-doc.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/moons-MP.mkiv
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/moons-MP.mkiv (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/moons-MP.mkiv 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,86 @@
+%D \module
+%D [ file=t-pocketdiary,
+%D version=2023-04-15,
+%D title=PocketDiary \CONTEXT\ User Module,
+%D subtitle=Moon pictogrammes,
+%D author=Willi Egger,
+%D date=\currentdate,
+%D copyright=Willi Egger,
+%D email=w.egger at boede.nl,
+%D license=Public Domain]
+
+% \setupbodyfont[plex,ss,14pt]
+
+\defineMPinstance
+ [Moon]
+ [metafun]
+ []
+
+\startMPinclusions[]{Moon}
+ numeric w,h;
+ path p[];
+ pair ip[];
+
+ w = OverlayWidth;
+ h = OverlayHeight;
+
+ p[1] := fullcircle scaled h;
+ p[2] := p[1] shifted (0.2 w,0);
+
+ ip[1] := p[1] intersectionpoint p[2];
+ ip[2] := reverse p[1] intersectionpoint p[2];
+
+ p[3] := p[1] cutbefore ip[1] cutafter ip[2];
+ p[4] := p[2] cutbefore ip[1] cutafter ip[2];
+
+ drawoptions (withpen pencircle scaled 2pt);
+
+\stopMPinclusions
+
+\startuniqueMPgraphic{Moon::Waning_moon}
+ draw p[3] ;
+ draw p[4] ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{Moon::Growing_moon}
+ draw p[3] ;
+ draw p[4] ;
+ currentpicture := (currentpicture reflectedabout (ip[1],ip[2]));
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{Moon::Fullmoon}
+ draw p[1];
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{Moon::Newmoon}
+ fill p[1] withcolor 0.625 white;
+ draw p[1];
+\stopuniqueMPgraphic
+
+
+\defineoverlay[waningmoon][\useMPgraphic{Moon::Waning_moon}]
+\defineoverlay[growingmoon][\useMPgraphic{Moon::Growing_moon}]
+\defineoverlay[newmoon][\useMPgraphic{Moon::Newmoon}]
+\defineoverlay[fullmoon][\useMPgraphic{Moon::Fullmoon}]
+
+\defineframed
+ [Moon]
+ [height=\bodyfontsize,
+ width=\bodyfontsize,
+ frame=off]
+
+
+% \starttext
+% Results with \type{framed}
+%
+% \blank
+%
+% Heute ist abnehmender Mond {\Moon[background=waningmoon]{\strut}}
+%
+% Heute ist Vollmond \Moon[background=fullmoon]{}
+%
+% Heute haben wir Neumond \Moon[background=newmoon]{}
+%
+% Und heute haben wir zunehmenden Mond \Moon[background=growingmoon]{}
+%
+% \stoptext
\ No newline at end of file
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/t-moonphase.lua
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/t-moonphase.lua (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/t-moonphase.lua 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,108 @@
+if not modules then modules = { } end modules ['t-moonphase'] = {
+ version = "2023.04.15",
+ comment = "Moonphase calculation",
+ author = "SubSystems www.subsystems.us edited by Willi Egger",
+ copyright = "Willi Egger",
+ email = "w.egger at boede.nl",
+ license = "Public Domain"
+}
+
+thirddata = thirddata or { }
+thirddata.moonphase = { }
+local moonphase = thirddata.moonphase
+
+local report = logs.reporter("Lunar")
+
+--[[
+From an article published by SubSystems www.subsystems.us:
+
+Let’s calculate the phase of the moon on 3/1/2017:
+1) Express the date as Y = 2017, M = 3, D = 1.
+2) If the month is January or February, subtract 1 from the year and add 12 to the month
+ Since the month March (M=3), we don’t need to adjust the values.
+3) With a calculator, do the following calculations:
+
+a. A = Y/100 A = 20
+b. B = A/4 and then record the integer part B = 5
+c. C = 2-A+B and then record the integer part C = -13
+d. E = 365.25 x (Y+4716) record the integer part E = 2459228
+e. F = 30.6001 x (M+1) record the integer part F = 122
+f. JD = C+D+E+F-1524.5 JD = 2457813.5
+
+Now that we have the Julian day, let’s calculate the days since the last new moon:
+Day since New = 2457813.5 - 2451549.5 = 6264 days
+If we divide this by the period, we will have how many new moons there have been:
+New Moons = 6264 / 29.53 = 212.123 cycles
+Now, multiply the fractional part by 29.53:
+Days into cycle = 0.123 x 29.53 = 3.63 days since New Moon
+--]]
+
+function moonphase.julianday(y,m,d)
+ local year = y
+ local month = m
+ local day = d
+
+ if month == 1 or month == 2 then
+ year = year - 1
+ month = month + 12
+ end
+ local a = year/100
+ local b = math.floor(a/4)
+ local c = math.floor(2-a+b)
+ local e = math.floor(365.25*(year+4716))
+ local f = math.floor(30.6001*(month+1))
+ local jd = c + day + e + f - 1524.5
+
+ return jd
+end
+
+function moonphase.lunardays(y,m,d)
+ local year = y
+ local month = m
+ local day = d
+
+ report("Working in function: moonphase.lunardays")
+
+ local JD = moonphase.julianday(year,month,day)
+ local days = JD - 2451549.5 --2451549.5 is Julian date of 06-01-2000, a new moon date
+ local cycles = days / 29.53 --29.53 is lunar month
+ local moonphasedays = (cycles-math.floor(cycles))
+ moonphasedays = moonphase.round(moonphasedays*29.53)
+
+ --report("Tage im Mondzyclus: %s", moonphasedays)
+
+ if moonphasedays == 29 then
+ moonphasedays = 0;
+ end
+ if moonphasedays == 0 then
+ report("New Moon")
+ return ("\\Moon[background=newmoon]{}")
+ elseif moonphasedays == 7 then
+ report("Quarter Moon")
+ return ("\\Moon[background=growingmoon]{}")
+ elseif moonphasedays == 15 then
+ report("Full Moon")
+ return ("\\Moon[background=fullmoon]{}")
+ elseif moonphasedays == 22 then
+ report("Three Quarter Moon")
+ return ("\\Moon[background=waningmoon]{}")
+ else
+ return (moonphasedays);
+ end
+ ---return moonphasedays
+end
+
+--Lua does not have a round function. From the Internet:
+
+function moonphase.round(num)
+ local under = math.floor(num)
+ local upper = math.floor(num) + 1
+ local underV = -(under - num)
+ local upperV = upper - num
+
+ if (upperV > underV) then
+ return under
+ else
+ return upper
+ end
+end
Property changes on: trunk/Master/texmf-dist/tex/context/third/pocketdiary/Moonphase/t-moonphase.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/PocketDiary.mkiv
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/PocketDiary.mkiv (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/PocketDiary.mkiv 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,119 @@
+%D \module
+%D [ file=t-pocketdiary.tex,
+%D version=2023.04.15,
+%D title=PocketDiary,
+%D subtitle=User file for PocketDiary,,
+%D author=W. Egger,
+%D date=\currentdate,
+%D copyright=W. Egger,
+%D license=Public Domain]
+
+
+%D This is the base for the compilation of a PocketDiary.
+%D Please refer to the documentation of the module to see
+%D which options you have to make up your own layout for the PocketDiary
+%D This module is built for usage withKIV and LUAMETATEX (LMTX)
+
+%D Load the PocketDiary module
+\usemodule[pocketdiary]
+
+%D Choose and setup the desired font to be used
+
+\setupbodyfont[ibmplex,rm,8pt]
+
+\definefontfeature[f:tabular][tnum=yes]
+\addfeature[f:tabular]
+
+%D Set the main language, which sets the interface to be used. Supported interfaces: EN,DE,NL,FR,IT,ES,PL
+
+\mainlanguage[en]
+
+%D setup the paper size and mapping onto the print paper
+
+\setuppapersize[A6][A4,landscape]
+
+%D Setup of the different variable sets of the PocketDiary
+
+\setvariables
+ [PocketDiary]
+ [WeekDay=1,
+ Week=15,
+ Month=4,
+ Year=2023,
+ Nextyear=yes,
+ Daybyday=no]
+
+%D If "Daybyday = yes" then the first 6 pages are filled with 5 times a single
+%D day and the weekend is 1 page. The pages 7 and 8 are filled with what is set
+%D in PockedDiaryLayout for page 7 and 8.
+
+\setvariables
+ [PocketDiaryLayout]
+ [Page1=Dayplan,
+ Page2=Weekendplan,
+ Page3=Weekcurrentplan,
+ Page4=Weeknextplan,
+ Page5=Monthcurrentplan,
+ Page6=Monthnextplan,
+ Page7=Yearcurrentplan,
+ Page8=Lost-Returnto]
+
+
+%D Names of included templates: You are allowed to use the same template
+%D on multiple pages.
+%D \startlines
+%D Dayplan
+%D Weekcurrentplan
+%D Weekendplan
+%D Weeknextplan
+%D Monthcurrentplan
+%D Monthnextplan
+%D Yearcurrentplan
+%D Yearnextplan
+%D Lines
+%D Blank
+%D Caro
+%D Todo
+%D Contact
+%D Lost-Returnto
+%D \stoplines
+
+\setvariables
+ [PocketDiaryAddress]
+ [Familyname={YourFamilyName},
+ Forename={YourFirstName},
+ Street=Pine Lane
+ Zipcode=2080,
+ City=YourTown,
+ Country=YourCountry,
+ Phone={\dots},
+ Mobile={\dots},
+ E-mail={\dots},
+ Web={\dots}]
+
+\setvariables
+ [PocketDiaryFooter]
+ [Lefttext={\getvariable{PocketDiaryAddress}{Forename}~
+ \getvariable{PocketDiaryAddress}{Familyname}},
+ Centertext=,
+ Righttext=\pagenumber]
+
+\setvariables
+ [PocketDiaryColors]
+ [Separatorline=blue,
+ Gridline={s=0.55}]
+
+\setvariables %Dreifelden
+ [PocketDiaryGeoPosition]
+ [lat=52.467860,
+ lon=16.981240,
+ timezoneoffset=1,
+ continent=US] % EU, US or leave empty for no DST
+
+%D Setup the document
+\starttext
+
+ \setuparranging[1*8] % this can be uncommented in t-pocketdiary.tex
+
+ \getbuffer[Pocketdiary]
+\stoptext
\ No newline at end of file
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/sun-MP.nkiv
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/sun-MP.nkiv (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/sun-MP.nkiv 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,137 @@
+%D \module
+%D [ file=t-pocketdiary,
+%D version=2023-04-15,
+%D title=PocketDiary \CONTEXT\ User Module,
+%D subtitle=Sun pictogrammes,
+%D author=Willi Egger,
+%D date=\currentdate,
+%D copyright=Willi Egger,
+%D email=w.egger at boede.nl,
+%D license=Public Domain]
+
+% \setupbodyfont[plex,ss,14pt]
+
+\defineMPinstance
+ [Sun]
+ [metafun]
+ []
+
+\startMPinclusions[]{Sun}
+ numeric w,h;
+ path p[];
+ pair ip[];
+
+ w = OverlayWidth;
+ h = OverlayHeight;
+
+ p[1] := fullcircle scaled h;
+ p[100] := tcircle scaled 0.5h; %h
+ p[2] := tcircle scaled 0.6h; %1.2h;
+ p[3] := tcircle scaled 0.75h; %1.6h;
+ p[4] := tcircle scaled h; %2h;
+ p[5] := (0,0)--point 1 of p[4] ;
+ p[6] := p[5] cutbefore point .3 of p[5];
+ p[7] := p[6] rotatedaround (center p[1],18);
+
+ ip[1] := p[2] intersectionpoint p[7];
+ ip[2] := p[3] intersectionpoint p[7];
+
+ p[10] := ip[1]--ip[2];
+
+ ip[3] := ip[1];
+ ip[4] := point 1 of p[7];
+
+ p[11] := ip[3]--ip[4];
+
+ drawoptions (withpen pencircle scaled 0.25pt withcolor red);
+
+\stopMPinclusions
+
+\startreusableMPgraphic{Sun::Sunrise}
+ drawoptions (withpen pencircle scaled 0.25pt withcolor red);
+ draw p[100];
+ for i = 36 step 36 until 154 :
+ draw p[10] rotatedaround (center p[1],i-18);
+ endfor;
+ for i = 18 step 36 until 180 :
+ draw p[11] rotatedaround (center p[1],i-18);
+ endfor;
+ drawarrow ((0,0)--(0,h)) shifted (0,-0.05h);
+\stopreusableMPgraphic
+
+\startreusableMPgraphic{Sun::Sunset}
+ drawoptions (withpen pencircle scaled 0.25pt withcolor red);
+ draw p[100];
+ for i = 36 step 36 until 154 :
+ draw p[10] rotatedaround (center p[1],i-18);
+ endfor;
+ for i = 18 step 36 until 180 :
+ draw p[11] rotatedaround (center p[1],i-18);
+ endfor;
+ drawarrow ((0,h)--(0,0)) shifted (0,-0.05h) xscaled 0.5;
+\stopreusableMPgraphic
+
+\startreusableMPgraphic{Sun::Light}
+ h := OverlayHeight;
+ w := OverlayWidth;
+ drawoptions (withpen pencircle scaled 0.15pt withcolor red);
+
+ p[11] := ip[3]--ip[4];
+ p[1] := fullcircle scaled 0.25h;
+ p[2] := tcircle scaled 0.35h;
+ p[3] := tcircle scaled 0.5h;
+ p[4] := tcircle scaled 0.8h;
+ p[5] := (0,0)--point 1 of p[4] ;
+ p[6] := p[5] cutbefore point .3 of p[5];
+ p[7] := p[6] rotatedaround (center p[1],18);
+
+ ip[1] := p[2] intersectionpoint p[7];
+ ip[2] := p[3] intersectionpoint p[7];
+
+ p[10] := ip[1]--ip[2];
+
+ ip[3] := ip[1];
+ ip[4] := point 1 of p[7];
+
+ p[11] := ip[3]--ip[4];
+
+ draw p[1];
+ for i = 36 step 36 until 360 :
+ draw p[10] rotatedaround (center p[1],i-18);
+ endfor;
+ for i = 18 step 36 until 360 :
+ draw p[11] rotatedaround (center p[1],i-18);
+ endfor;
+
+ currentpicture := currentpicture rotatedaround(center p[1],18);
+\stopreusableMPgraphic
+
+\defineoverlay[Sunrise][\useMPgraphic{Sun::Sunrise}]
+\defineoverlay[Sunset][\useMPgraphic{Sun::Sunset}]
+\defineoverlay[Light][\useMPgraphic{Sun::Light}]
+
+\defineframed
+ [SunA]
+ [strut=yes,
+ height=\lineheight,
+ width=\emwidth,
+ frame=off,
+ offset=0pt]
+
+\defineframed
+ [SunB]
+ [strut=yes,
+ height=\lineheight,
+ width=\emwidth,
+ frame=off,
+ offset=0pt,
+ location=depth]
+
+% \starttext
+% \setupbodyfont[8pt] % This is the minimal size which looks still ok.
+%
+% Sunrise: {\SunA[background=Sunrise]{\strut}}
+% Sunset: \SunA[background=Sunset]{\strut}
+% Light hours: \SunB[background=Light]{\strut} Sunshine
+%
+% \stoptext
\ No newline at end of file
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/t-solar.lua
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/t-solar.lua (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/t-solar.lua 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,256 @@
+if not modules then modules = { } end modules ['t-solar'] = {
+ version = "2023.04.15",
+ comment = "Sun rise and sun set calculation",
+ author = "Alexander Yakushev, edited by Willi Egger",
+ copyright = "Willi Egger",
+ email = "w.egger at boede.nl",
+ license = "CC0 http://creativecommons.org/about/cc0"
+}
+
+thirddata = thirddata or { }
+thirddata.srss = { }
+local srss = thirddata.srss
+
+local report = logs.reporter("Solar data")
+
+--[[ Module for calculating sunrise/sunset times for a given location
+ Based on algorithm by United States Naval Observatory, Washington
+ Link: http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
+ @author Alexander Yakushev
+ @license CC0 http://creativecommons.org/about/cc0
+--]]
+
+local rad = math.rad
+local deg = math.deg
+local floor = math.floor
+
+local mcos = math.cos
+local msin = math.sin
+local mtan = math.tan
+
+local macos = math.acos
+local masin = math.asin
+local matan = math.atan
+
+local frac = function(n) return n - floor(n) end
+local cos = function(d) return mcos(rad(d)) end
+local acos = function(d) return deg(macos(d)) end
+local sin = function(d) return msin(rad(d)) end
+local asin = function(d) return deg(masin(d)) end
+local tan = function(d) return mtan(rad(d)) end
+local atan = function(d) return deg(matan(d)) end
+
+function srss.fit_into_range(val,min,max)
+ local range = max - min
+ if val < min then
+ return val + (floor((min - val) / range) + 1) * range
+ elseif val >= max then
+ return val - (floor((val - max) / range) + 1) * range
+ else
+ return val
+ end
+end
+
+function srss.day_of_year(date)
+ local n1 = floor(275 * date.month / 9)
+ local n2 = floor((date.month + 9) / 12)
+ local n3 = (1 + floor((date.year - 4 * floor(date.year / 4) + 2) / 3))
+ return n1 - (n2 * n3) + date.day - 30
+end
+
+function srss.sunturn_time(
+ date,rising,latitude,longitude,zenith,local_offset,DST)
+
+ local n = srss.day_of_year(date)
+
+ -- report("working in function: srss.sunturn_time")
+ -- report("Day: %s Month: %s Year: %s", date.day, date.month, date.year)
+ -- report("Latitude: %s Longitude %s Timeoffset %s", latitude, longitude,
+ -- local_offset)
+
+ -- Convert the longitude to hour value and calculate an approximate time
+ local lng_hour = longitude / 15
+
+ --report("longitude hour %s", lng_hour)
+
+ local t
+ if rising then -- Rising time is desired
+ t = n + ((6 - lng_hour) / 24)
+ else -- Setting time is desired
+ t = n + ((18 - lng_hour) / 24)
+ end
+
+ -- Calculate the Sun's mean anomaly
+ local M = (0.9856 * t) - 3.289
+
+ -- Calculate the Sun's true longitude
+
+ local L = srss.fit_into_range(M + (1.916 * sin(M)) + (0.020 * sin(2 * M)) +
+ 282.634, 0, 360)
+
+ -- Calculate the Sun's right ascension
+ local RA = srss.fit_into_range(atan(0.91764 * tan(L)), 0, 360)
+
+ -- Right ascension value needs to be in the same quadrant as L
+
+ local Lquadrant = floor(L / 90) * 90
+ local RAquadrant = floor(RA / 90) * 90
+ RA = RA + Lquadrant - RAquadrant
+
+ -- Right ascension value needs to be converted into hours
+ RA = RA / 15
+
+ -- Calculate the Sun's declination
+ local sinDec = 0.39782 * sin(L)
+ local cosDec = cos(asin(sinDec))
+
+ -- Calculate the Sun's local hour angle
+
+ local cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec *
+ cos(latitude))
+
+ if rising and cosH > 1 then
+
+ -- return "N/R" -- The sun never rises on this location on the specified
+ -- date
+ report("Sun does not rise")
+
+ return ("\\labeltext{sunrise}: --")
+ elseif cosH < -1 then
+ -- return "N/S" -- The sun never sets on this location on the specified date
+
+ report("Sun does not set")
+ return ("\\labletext{sunset}: --")
+ end
+
+ -- Finish calculating H and convert into hours
+ local H
+ if rising then
+ H = 360 - acos(cosH)
+ else
+ H = acos(cosH)
+ end
+ H = H / 15
+
+ -- Calculate local mean time of rising/setting
+ local T = H + RA - (0.06571 * t) - 6.622
+
+ -- Adjust back to UTC
+ local UT = srss.fit_into_range(T - lng_hour, 0, 24)
+
+ -- Convert UT value to local time zone of latitude/longitude
+ local LT = UT + local_offset
+
+ -- Include daylight saving
+ -- report("UT: %s", UT)
+ -- report("LT: %s", LT)
+
+ if DST == true then
+ -- report("DST is on")
+ LT = LT + 1
+ end
+
+ -- report("DST: %s", LT)
+
+ return LT
+end
+
+function srss.get(d,mon,yr,lat,lon,offset,dst_start,dst_stop)
+
+ local date = { year = yr, month = mon, day = d } -- os.date("*t")
+ local lat = lat
+ local lon = lon
+ local offset = offset
+ local zenith = 90.83
+ local dst_start = dst_start
+ local dst_stop = dst_stop
+
+ -- report("Latidude : %s",lat)
+ -- report("Longitude : %s",lon)
+ -- report("Offset : %s",offset)
+ -- report("Zenith : %s",zenith)
+ -- report("Datum : %02i-%02i-%02i",date.year,date.month,date.day)
+ -- report("DST begin in srss.get : %s",dst_start)
+ -- report("DST end in srss.get : %s",dst_stop)
+
+ -- determine whether the day for sun rise/set is with daylight saving
+ local DST
+
+ if dst_start ~= "none" then
+ local dst_startday = tonumber(srss.ordinalday(dst_start))
+ local dst_endday = tonumber(srss.ordinalday(dst_stop))
+ local calendarday = srss.ordinalday(date.year.."/"
+ ..date.month.."/"..date.day)
+
+ --report("Ordinal calendar day: %s", calendarday)
+
+ if (calendarday <= dst_endday) and (calendarday >= dst_startday) then
+ DST = true
+ else
+ DST = false
+ end
+ else
+ DST = false
+ end
+
+ local rise_time = srss.sunturn_time(date,true,lat,lon,zenith,offset,DST)
+ local set_time = srss.sunturn_time(date,false,lat,lon,zenith,offset,DST)
+
+ if type(rise_time) ~= "number" then return rise_time end
+ if type(set_time) ~= "number" then return set_time end
+
+ local hourfraction = srss.minutes(rise_time)
+ local rise_hour = floor(rise_time)..":"..hourfraction
+ local hourfraction = srss.minutes(set_time)
+ local set_hour = floor(set_time)..":"..hourfraction
+ local length = (set_time - rise_time)
+ local hourfraction = srss.minutes(length)
+ local light_hours = floor(length)..":"..hourfraction
+
+ --report("Sun rise : %s",rise_hour)
+ --report("Sun set : %s",set_hour)
+ --report("Light hours : %s",light_hours)
+
+ return rise_hour, set_hour, light_hours
+end
+
+function srss.minutes(time)
+ return string.formatters["%02i"](floor((time - floor(time))*60))
+end
+
+function srss.ordinalday(inputstr)
+
+ --report("Input : %s",inputstr)
+
+ local sep = "%-%s/"
+ if sep == nil then
+ sep = "%s"
+ end
+ local t={}
+ i=1
+ for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
+ t[i] = str
+ i = i + 1
+ end
+
+ --report("Datum strings: %s, %s, %s", t[1],t[2],t[3])
+
+ local daynumber = os.date("*t",os.time{year=t[1],month=t[2],day=t[3]})
+ local ordinalday = daynumber.yday
+
+ --report("Day of year : %s",ordinalday)
+
+ return ordinalday
+end
+
+function srss.sundata(...)
+ local r, s, l = srss.get(...)
+
+ report("Working in function: srss.sundata")
+
+ if r and s and l then
+ return r, s, l
+ else
+ return r
+ end
+end
Property changes on: trunk/Master/texmf-dist/tex/context/third/pocketdiary/Solar/t-solar.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-calendar.lua
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-calendar.lua (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-calendar.lua 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,720 @@
+if not modules then modules = { } end modules ['t-calendar'] = {
+ version = "2023.04.15",
+ comment = "Date calculation collection",
+ author = "Willi Egger",
+ copyright = "Willi Egger",
+ email = "w.egger at boede.nl",
+ license = "Public Domain"
+ }
+
+thirddata = thirddata or { }
+thirddata.calendar = { }
+local calendar = thirddata.calendar
+
+local report = logs.reporter("Calendar")
+
+-- Determine whether the year is a leap year
+
+function calendar.isleapyear(year)
+ local yeardays
+ if (year % 4 == 0) and (year % 100 ~= 0 or year % 400 == 0) then
+ yeardays = 366
+ else
+ yeardays = 365
+ end
+
+ -- report("Days in the year in function calendar.isleapyear: %d",yeardays)
+
+ return yeardays
+end
+
+-- Lua calculates day 1 = sunday, day 0 = saturday
+--
+-- Calculate the weekday of 1st of january according to S. Babwani
+-- w = floor(5*year/4)+f(m)+d- 2 * mod(cn,4)
+-- where w is the week day
+-- where year is the last two digits of the full year.
+-- where f(m) is 0 for january (See table 3 of Babwani's congruence)
+-- where d is the day: 1 for january
+-- where cn is the century
+
+function calendar.janfirst(y)
+ local year = y
+
+ -- report("Working in function: calendar.janfirst")
+ -- report("Year in function: calendar.janfirst: %d",year)
+
+ local cn = math.floor(year/100) -- century
+ local yr = math.fmod(year,100) -- year without century
+ local leap_year = calendar.isleapyear(year) -- returns values 365 or 366
+
+ -- report("Century %d",cn)
+ -- report("Year without century %d",yr)
+ -- report("Result of check for leapyear (days) %d",leap_year)
+
+ local janfirst
+
+ if leap_year == 365 then
+ janfirst = math.fmod((math.floor((5 * yr) / 4)
+ + 0 + 1 - (2 * (math.fmod(cn,4)))),7)
+ else
+ janfirst = math.fmod((math.floor((5 * yr) / 4)
+ + 6 + 1 - (2 * (math.fmod(cn,4)))),7)
+ end
+
+ --report("Weekday of January 1st in function calendar.janfirst: %d",janfirst)
+
+ return janfirst
+end
+
+-- Calculate the ordinal number of a given day of the year from the weeknumber
+
+function calendar.wknrordinal(wkdjf,wk,yr)
+ local weekdayjanfirst = wkdjf
+ local weeknumber = wk
+ local year = yr
+
+ report("Working in calendar.wknrordinal")
+ --report("Weeknumber %d, Year: %d", weeknumber,year)
+
+ -- This table contains the offset of the first monday after the 1st of
+ -- january,
+ -- as used in the calculation of the ordinal number of a day of the year
+
+ local dyearbegin = {1,0,6,5,4,3,2}
+
+ local ordinalday = (weeknumber - 1) * 7 + dyearbegin[weekdayjanfirst]
+
+ --report("Ordinal day in calendar.wknrordinal: %d", ordinalday)
+
+ leapyear = calendar.isleapyear(year)
+
+ if ordinalday > leapyear then
+ ordinalday = ordinalday - 7
+ end
+
+ return ordinalday
+end
+
+-- Calculate the first day of a week calendar based on the week day of the 1st
+-- of january, date calculations based on the OS-timestamp
+
+function calendar.weekcalendar(wk,mn,yr)
+ local weeknumber = wk
+ local month = mn
+ local year = yr
+
+ report("Working in function: calendar.weekcalendar")
+ --report("Week number: %d Year: %d",weeknumber,year)
+
+ --report("Week number in function calendar.weekcalendar %d", weeknumber)
+
+ if month == 1 and weeknumber > 51 then
+ year = year -1
+ end
+
+ local weekdayjanfirst = calendar.janfirst(year)
+
+ --report("Weekday of January 1st from function calendar.weekcalendar: %d",weekdayjanfirst)
+
+ if weekdayjanfirst == 0 then weekdayjanfirst = 7 end
+
+ local janfirsttimestamp = os.time({year=year,month=1,day=1})
+
+ -- report("January 1st timestamp: %d", janfirsttimestamp)
+
+ local startday = janfirsttimestamp
+ local ordinalday = calendar.wknrordinal(weekdayjanfirst,weeknumber,year)
+
+ --report("Ordinal day (function: calendar.weekcalendar): %d",ordinalday)
+
+ if weekdayjanfirst > 1 and weekdayjanfirst <= 5 and weeknumber == 1 then
+ startday = janfirsttimestamp - (weekdayjanfirst-1) * 24 * 60 * 60
+ elseif
+ weekdayjanfirst == 3 or weekdayjanfirst == 4 or weekdayjanfirst == 5 and weeknumber ~= 1 then
+ startday = janfirsttimestamp + (ordinalday-8) * 24 * 60 * 60
+ else
+ startday = janfirsttimestamp + (ordinalday-1) * 24 * 60 * 60
+ end
+
+ if ordinalday > 360 then
+ startday = janfirsttimestamp + (ordinalday-1) * 24 * 60 * 60
+ end
+
+ -- local q = os.date("%x",startday)
+--
+--report("Start day of chosen week from function calendar.janfirst: %s", q)
+
+ return startday
+end
+
+-- Select a weekday from the os.date table and return the day name value to ConTeXt
+
+function calendar.select_dayname(d,wk,mn,y)
+ local weekday = d
+ local weeknumber = wk
+ local month = mn --not used but necessary for calendar.weekcalendar
+ local year = y
+
+ local startday = calendar.weekcalendar(weeknumber,month,year)
+ local d = startday + weekday * 24 * 60 * 60
+ local s = string.lower(os.date("%a",d))
+
+ -- report("Working in function: calendar.select_dayname")
+
+ local t = os.date("%d-%m-%Y",d)
+
+ -- report("Startday+day! : %s", t)
+ -- report("Day name: %s", s)
+
+ return s
+end
+
+-- Select a date from the os.date table and return the value to ConTeXt
+
+function calendar.select_fulldate(weeknumber,year,day)
+
+ local month = 5 --not used but necessary for calendar.weekcalendar
+ local startday = calendar.weekcalendar(weeknumber,month,year)
+ local d = startday + day * 24 * 60 * 60
+ local s = os.date("%d-%m-%Y",d)
+
+ -- report("Working in function: calendar.select_fulldate")
+
+ return context(s)
+end
+
+-- Select an ordinal day from the os.date table and return the day name value to ConTeXt
+
+function calendar.select_dayofmonth(d,wk,mn,y)
+
+ local day = d
+ local weeknumber = wk
+ local month = mn
+ local year = y
+
+ -- report("Working in function: calendar.select_dayofmonth")
+ -- report("Weeknumber: %s , Year: %s, Day: %s", weeknumber,year,day)
+
+ local startday = calendar.weekcalendar(weeknumber,month,year)
+ local d = startday + day * 24 * 60 * 60
+ local s = os.date("%d",d)
+ local b = string.lower(os.date("%a",d))
+ local t = os.date("%d-%m-%Y",d)
+
+ -- report("Asked day : %s", t)
+ -- report("B Dayname: %s", b)
+
+ s = tonumber(s)
+
+ -- report("B Day number of month: %d", s)
+
+ return s
+end
+
+-- Select the month number from the os.date table and return the value as a number
+
+function calendar.select_month(d,wk,y)
+
+ local weeknumber = wk
+ local year = y
+ local day = d
+ local month = 5 -- this is not used, but necessary for using calendar.weekcalendar
+
+ -- report("Working in function: calendar.select_month")
+ -- report("Day: %s, Weeknumber %s, Year: %s", day,weeknumber,year)
+
+ local startday = calendar.weekcalendar(weeknumber,month,year)
+ local d = startday + day * 24 * 60 * 60
+ local s = os.date("%m",d)
+
+ -- report("select month: %s", s)
+
+ return s
+end
+
+-- Select the month name from the os.date table and return the name of the month
+
+function calendar.select_monthname(d,wk,mn,y)
+
+ local day = d
+ local weeknumber = wk
+ local month = mn -- this is not used, but necessary for using calendar.weekcalendar
+ local year = y
+
+
+ -- report("Working in function: calendar.select_monthname")
+ -- report("Day: %s, Week: %s, Year: %s", day,weeknumber,year)
+
+ local startday = calendar.weekcalendar(weeknumber,month,year)
+ local t = startday + day * 24 * 60 * 60
+ local s = string.lower(os.date("%B",t))
+
+
+ return s
+end
+
+-- Select the fullyear from the os.date table and return the value
+
+function calendar.select_fullyear(weeknumber,year,day)
+
+ local month = 5 --not used, but necessary for using calendar.weekcalendar
+ local startday = calendar.weekcalendar(weeknumber,month,year)
+ local d = startday + day * 24 * 60 * 60
+ local s = os.date("%Y",d)
+
+ -- report("Working in function: calendar.select_fullyear")
+
+ return s
+end
+
+-- Select the monthname (long) based on month-number from os.date
+
+function calendar.select_nameofmonth(mon,y)
+
+ -- report("Working in function: calendar.select_nameofmonth")
+
+ local monthnumber = mon
+ local year = y
+ local d = 1
+ local m = string.lower(os.date("%B",
+ os.time{year=year,month=monthnumber,day=d}))
+
+ -- report("Month name %s",m)
+
+ return m
+end
+
+-- Select the monthname (long) based on monthnumber from os.date and return it as a labeltext
+
+function calendar.select_nameofmonthlabel(mon,y)
+
+ -- report("Working in function: calendar.select_nameofmonthlabel")
+
+ local monthnumber = mon
+ local year = y
+ local d = 1
+ local m = string.lower(os.date("%B",
+ os.time{year=year,month=monthnumber,day=d}))
+
+ -- report("Month name %s",m)
+
+ return context.labeltext(m)
+end
+
+-- Select the year from the os.date table and return the value to ConTeXt
+
+function calendar.select_year(weeknumber,year,day)
+ local month = 5 --not used but necessary for calendar.weekcalendar
+ local startday = calendar.weekcalendar(weeknumber,month,year)
+ local d = startday + day * 24 * 60 * 60
+ local s = os.date("%y",d)
+
+ -- report("Working in function: calendar.select_year")
+
+ return s --context(s)
+end
+
+--[[
+ EASTER DATE CALCULATION FOR YEARS 1583 TO 4099
+
+ y is a 4 digit year 1583 to 4099
+ d returns the day of the month of Easter
+ m returns the month of Easter
+
+ Easter Sunday is the Sunday following the Paschal Full Moon
+ (PFM) date for the year
+
+ This algorithm is an arithmetic interpretation of the 3 step
+ Easter Dating Method developed by Ron Mallen 1985, as a vast
+ improvement on the method described in the Common Prayer Book
+
+ Because this algorithm is a direct translation of the
+ official tables, it can be easily proved to be 100% correct
+
+ This algorithm derives values by sequential inter-dependent
+ calculations, so ... DO NOT MODIFY THE ORDER OF CALCULATIONS!
+
+ All variables are integer data types
+
+ It's free!
+
+ Comment: Translated from a BASIC-source into lua by W. Egger, 11-2010
+--]]
+
+function calendar.eastercalculation(y)
+ local year = y
+ local FirstDig = math.floor(year / 100) --first 2 digits of year
+ local Remain19 = math.fmod(year,19) --remainder of year / 19
+ local temp
+ local a = {}
+ local tA
+ local tB
+ local tC
+ local tD
+ local tE
+ local m
+ local d
+
+ -- calculate Paschal Full Moon (PFM) date
+
+ temp = math.floor((FirstDig - 15) / 2) + 202 - 11 * Remain19
+ a = {21, 24, 25, 27, 28, 29, 30, 31, 32, 34, 35, 38}
+ for val in pairs(a) do
+ if val == FristDig then
+ temp = temp - 1
+ break
+ end
+ end
+
+ a = {33, 36, 37, 39, 40}
+ for val in pairs(a) do
+ if val == FirstDig then
+ temp = temp - 2
+ break
+ end
+ end
+
+ temp = math.fmod(temp, 30)
+ tA = temp + 21
+
+ if temp == 29 then
+ tA = tA - 1
+ end
+
+ if (temp == 28 and Remain19 > 10) then
+ tA = tA - 1
+ end
+
+ --find the next Sunday
+
+ tB = math.fmod((tA - 19), 7)
+ tC = math.fmod((40 - FirstDig), 4)
+
+ if tC == 3 then
+ tC = tC + 1
+ end
+
+ if tC > 1 then
+ tC = tC + 1
+ end
+
+ temp = math.fmod(year, 100)
+ tD = math.fmod(temp + math.floor(temp/ 4), 7)
+ tE = math.fmod((20 - tB - tC - tD), 7) + 1
+
+ d = tA + tE
+
+ -- return the date
+
+ if d > 31 then
+ d = d - 31
+ m = 4
+ else
+ m = 3
+ end
+
+ -- return context("Year: " ..year .." month:" ..m .. " day: " ..d)
+
+ local odes = calendar.ordinalday(d,m,year)
+
+ -- report("Easter ordinal day: %s", odes)
+
+ return odes
+end
+
+-- Calculate the ordinal daynumber from a given date with os.date and os.time
+
+function calendar.ordinalday(day,month,year)
+
+ -- report("Working in function: calendar.ordinalday")
+
+ local t = os.date("*t",os.time{year=year,month=month,day=day})
+ local od = t.yday
+ return od
+end
+
+--Check a date whether it is a Christian feast
+
+function calendar.checkchristianfeast(d,m,y)
+
+ --report("Working in function: calendar.checkchristianfeast")
+ --report("Check Christian Feast: Day: %s, Month: %s, Year: %s", d,m,y)
+
+ local daynumber = d
+ local month = m
+ local year = y
+ local odes = calendar.eastercalculation(year)
+ local od = calendar.ordinalday(daynumber,month,year)
+
+ -- report("Result easter calculation: %s", odes)
+ -- report("Ordinal day to be checked: %s", od)
+
+ local s = nil
+ if month == 1 and od == 1 then
+ s = "nyd"
+ end
+ if month == 1 and od == 6 then
+ s = "epi"
+ end
+ if month < 7 then -- Easter depending feasts are never later than june
+ if od == odes - 46 then
+ s = "ashw"
+ elseif od == odes - 7 then
+ s = "palms"
+ elseif od == odes - 2 then
+ s = "gfri"
+ elseif od == odes then
+ s = "esun"
+ elseif od == odes + 1 then
+ s = "esmo"
+ elseif od == odes + 39 then
+ s = "ascd"
+ elseif od == odes + 49 then
+ s= "pcst"
+ elseif od == odes + 50 then
+ s= "pcstmo"
+ end
+ end
+ if month == 12 and daynumber == 25 then
+ s = "xmas"
+ end
+ if month == 12 and daynumber == 26 then
+ s = "bxd"
+ end
+
+ if s == nil then
+ s = ""
+ end
+
+ -- report("Result of christian holiday: %s", s)
+
+ return s
+end
+
+
+--Create a table with the number of days per month, accounting for leapyears and return the number of days to the calling function
+
+local dayspermonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+local nofdays = 0
+
+function calendar.nofdays_month(month,year)
+
+ -- report("Working in function: calendar.nofdays_month")
+
+ if month == 2 and calendar.isleapyear(year) ~= 365 then
+ nofdays = dayspermonth[month] + 1
+ else
+ nofdays = dayspermonth[month]
+ end
+
+ return nofdays
+
+end
+
+-- Create a table with the number of days per month, accounting for leapyears
+-- and return the number of weeks of the given month to the calling function
+
+function calendar.month(month,year)
+
+ report("Working in function: calendar.month")
+
+ local month = tonumber(month)
+
+ if month == 2 and calendar.isleapyear(year) ~= 365 then
+ nofdays = dayspermonth[month] + 1
+ else
+ nofdays = dayspermonth[month]
+ end
+
+ -- report ("Number of days : %s",nofdays)
+
+ monthtable = {}
+
+ local s = os.date("*t", os.time{year=year,month=month,day=1})
+
+ -- report("os.date: week day : %s",s.wday)
+
+ --Correcting the fact that lua starts the week on sunday
+
+ local wday = s.wday - 1
+ if wday == 0 then
+ wday = 7
+ end
+
+ -- report("Week day : %s",wday)
+
+ local beginmonth = wday-1
+
+ for i = 1, beginmonth do
+ table.insert(monthtable, 0)
+ end
+
+ for i = wday, (nofdays + beginmonth) do
+ table.insert(monthtable, i - wday + 1)
+ end
+
+ for i = (nofdays + beginmonth + 1), 42 do --a month table is max. 7 x 6 fields
+ table.insert(monthtable, 0)
+ end
+
+ local wkf = calendar.weeknumber(1,month,year)
+ local wkl = calendar.weeknumber(nofdays,month,year)
+
+ -- report("monthtable nofdays : %s",nofdays)
+ -- report("monthtable wkf : %s",wkf)
+ -- report("monthtable wkl : %s",wkl)
+
+ local b = wkl - wkf + 1
+
+ if month > 1 and month < 12 then
+ b = wkl - wkf + 1
+ elseif month == 12 and wkl == 1 then
+ wkl = 53
+ b = wkl - wkf + 1
+ elseif month == 1 and wkf > 51 then
+ b = wkl + 1
+ end
+
+ --report("number of weeks %s in month %s",b,month)
+
+ return b
+end
+
+--Select a day from the month table return value to context
+
+function calendar.dayselectofmonth(day)
+
+ -- report("Working in function calendar.dayselectofmonth")
+ -- report("Selected day : %s",day)
+
+ local s = monthtable[day]
+
+ -- report("Selected day from the monthtable: %s", s)
+
+ if s == 0 then
+ s = ""
+ return s --context(s)
+ else
+ return s --context(s)
+ end
+end
+
+--Generate the month name with os.date and os.time
+
+function calendar.monthname(mon,y)
+ local month = mon
+ local year = y
+
+ if month > 12 then
+ month = month - 12
+ year = year + 1
+ end
+
+ local s = string.lower(os.date("%B",os.time{year=year,month=month,day=1}))
+
+ -- report("month name : %s",s)
+
+ return s
+end
+
+
+-- http://www.irt.org/script/914.htm, Java, Ferry van Schaik
+-- Get the ISO week number from a given date for Europe
+--USA
+--[[
+function calendar.weeknumber(day,month,year)
+ local when = os.time({year=year,month=month,day=day})
+ local modDay = tonumber(os.date("%w",os.time({year=year,month=1,day=1})))
+
+ report("modDay in US calendar.weeknumber: %s",modDay)
+
+ local offset = 7 + 1 - modDay
+ if offset == 8 then
+ offset = 1
+ end
+
+ local daynum = math.round((when - os.time({year=year,month=1,day=1})) /60/60/24) + 1
+
+ report("daynum in US calendar.weeknumber: %s",daynum)
+
+ local weeknum = math.floor((daynum-offset+7)/7);
+
+ report("Week number in calendar.weeknumber %s", weeknum)
+
+ if weeknum == 0 then
+ year = year - 1
+ local prevNewYear = tonumber(os.date
+ ("%w",os.time({year=year,month=1,day=1})))
+ local prevOffset = 7 + 1 - prevNewYear
+ if prevOffset == 2 or prevOffset == 8 then
+ weeknum = 53
+ else
+ weeknum = 52
+ end
+ end
+
+ return weeknum
+end
+--]]
+-- EUROPA
+
+function calendar.weeknumber(d,month,year)
+ local day = d
+
+ -- report("Working in function calendar.weeknumber")
+ -- report("Daynumber in function calendar.daynumber: %s", day)
+
+ local when = os.time({year=year,month=month,day=day})
+ local modDay = tonumber(os.date("%w",os.time({year=year,month=1,day=1})))
+
+ if modDay == 0 then
+ modDay = 6
+ else
+ modDay = modDay - 1
+ end
+
+ local daynum = math.round((when - os.time({year=year,month=1,day=1})) /60/60/24) + 1
+ local weeknum = 0
+
+ if modDay < 4 then
+ weeknum = math.floor((daynum+modDay-1)/7)+1
+ else
+ weeknum = math.floor((daynum+modDay-1)/7)
+ if weeknum == 0 then
+ local prevmodDay = tonumber(os.date("%w",os.time({year=year-1,month=1,day=1})))
+ if prevmodDay == 0 then
+ prevmodDay = 6
+ end
+ if prevmodDay < 4 then
+ weeknum = 53
+ else
+ weeknum = 52
+ end
+ end
+ end
+
+ return weeknum
+end
+
+
+-- Calculate the week number of a given monday of the year from the ordinal day number
+
+function calendar.ordinaltowknr(ordinalday,year)
+
+ -- This table contains the offset of the first monday after the 1st of
+ -- january,
+ -- as used in the calculation of the ordinal number of a day of the year
+
+ local dyearbegin = {1,0,6,5,4,3,2}
+ local weekdayjanfirst = calendar.janfirst(year)
+
+ if weekdayjanfirst == 0 then
+ weekdayjanfirst = 7
+ end
+
+ local wknumber = math.div(ordinalday - dyearbegin[weekdayjanfirst],7) + 1
+
+ return wknumber
+end
+
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-calendar.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.lua
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.lua (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.lua 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,854 @@
+if not modules then modules = { } end modules ['t-pocketdiary'] = {
+ version = "2023.04.15",
+ comment = "Layouts of diary pages",
+ author = "Willi Egger",
+ copyright = "Willi Egger",
+ email = "w.egger at boede.nl",
+ license = "Public Domain"
+}
+
+thirddata = thirddata or { }
+thirddata.diary = { }
+local diary = thirddata.diary
+
+local report = logs.reporter("Diary pages")
+
+function diary.data(wd,wk,mn,yr,la,lo,to,cont)
+
+ report("Working in function: diary.data")
+
+ local weekday = wd
+ local weeknumber = wk
+ local month = mn
+ local year = yr
+ local lon = lo
+ local lat = la
+ local timeoffset = to
+ local continent = cont
+ local moon = ""
+ local srise,sset,lhours
+
+ local dayofmonth = thirddata.calendar.select_dayofmonth(
+ weekday,weeknumber,month,year)
+
+ local dayname = thirddata.calendar.select_dayname(weekday,weeknumber,month,year)
+
+ local holiday = thirddata.calendar.checkchristianfeast(
+ dayofmonth,month,year)
+
+ local monthname = thirddata.calendar.select_monthname(
+ weekday,weeknumber,month,year)
+
+ local moondata = thirddata.moonphase.lunardays(year,month,dayofmonth)
+
+ local dst_start, dst_stop,srise,sset,lhours
+
+ if continent ~="" then
+ local dst_start,dst_stop = diary.DST(year,continent)
+
+ report("DST start: %s DST stop: %s",dst_start,dst_stop)
+
+ srise,sset,lhours = thirddata.srss.sundata(
+ dayofmonth,month,year,lat,lon,timeoffset,dst_start,dst_stop)
+ else
+ dst_start = "none"
+ dst_stop = 0
+ report("No DST is applied")
+ end
+
+ return weekday, weeknumber, month, year, lat, lon, timeoffset, dst_start,
+ dst_stop, dayofmonth, dayname, holiday, monthname, moondata, srise, sset,
+ lhours
+end
+
+function diary.DST(year,continent)
+ local report = logs.reporter("DST date")
+
+ report("Working in function DST")
+
+ local dstmonth_start
+ local dstmonth_stop
+ local dstday_start
+ local dstday_stop
+ local dst_start
+ local dst_stop
+
+ if continent ~= "" then
+ if continent == "EU" then
+ dstmonth_start = 3
+ dstmonth_stop = 10
+ dstday_start = diary.DSTday(dstmonth_start,year,continent)
+ dstday_stop = diary.DSTday(dstmonth_stop,year,continent)
+ else
+ if continent == "US" then
+ dstmonth_start = 3
+ dstmonth_stop = 11
+ dstday_start = diary.DSTday(dstmonth_start,year,continent)
+ dstday_stop = diary.DSTday(dstmonth_stop,year,continent)
+ end
+ end
+ -- report("DSTday start: %s",dstday_start)
+ -- report("DSTday stop: %s",dstday_stop)
+ dst_start = year.."-"..dstmonth_start.."-"..dstday_start
+ dst_stop = year.."-"..dstmonth_stop.."-"..dstday_stop
+ else
+ report("No DST to be taken in to account")
+ dst_start = "none"
+ dst_stop = 0
+ end
+
+ --report("DST start date: %s", dst_start)
+ --report("DST stop date: %s", dst_stop)
+
+ return dst_start, dst_stop
+end
+
+function diary.DSTday(month,year,continent)
+ report("Working in function DSTday")
+
+ local DSTday = {}
+ local dayname
+
+ if continent == "EU" then
+ -- the last Sunday of March and October can only be between 25. and 31. of the month
+ for i=25,31 do
+ dayname = string.lower(os.date
+ ("%a",os.time{day=i,month=month,year=year}))
+ DSTday[dayname] = i
+ end
+ else
+ -- for the US the second Sunday in March can be between 8. and 14. of March, first Sunday of November can be between 1. and 8. of November
+ if month == 3 then
+ for i=8,14 do
+ dayname = string.lower(os.date
+ ("%a",os.time{day=i,month=month,year=year}))
+ DSTday[dayname]=i
+ end
+ else
+ for i=1,7 do
+ dayname = string.lower(os.date
+ ("%a",os.time{day=i,month=month,year=year}))
+ DSTday[dayname]=i
+ end
+ end
+ end
+ return DSTday.sun
+end
+
+function diary.dayplan(...) --8 parameters
+
+ report("Working in function: diary.dayplan")
+
+ if weekday == 0 then
+ weekday = 1
+ end
+
+ local weekday, weeknumber, month, year, lat, lon, timeoffset, dst_start,
+ dst_stop, dayofmonth, dayname, holiday, monthname, moondata, srise, sset,
+ lhours = diary.data(...)
+
+ context.setupheadertexts{
+ function()
+ context.bTABLE({setups="table:topinfo"})
+ context.bTR()
+ context.bTD()
+ if dayname == "sun" or holiday ~= "" then
+ context.color({"red"},
+ function() context(dayofmonth) end)
+ context("~")
+ context.color({"red"},
+ function() context.labeltext(dayname) end)
+ else
+ context(dayofmonth)
+ context("~")
+ context.labeltext(dayname)
+ end
+ context.eTD()
+ context.bTD()
+ context.labeltext(holiday)
+ context.eTD()
+ context.bTD()
+ context.labeltext(monthname)
+ context("~")
+ context(year)
+ context.eTD()
+ context.eTR()
+ context.bTR({style="\\switchtobodyfont[5pt]"})
+ context.bTD()
+ if tonumber(moondata) then
+ context.labeltext("moondays")
+ else
+ context.labeltext("moon")
+ end
+ context(": ")
+ context(moondata)
+ context.eTD()
+ context.bTD({nx="2"})
+ context.dontleavehmode()
+ context("\\SunA[background=Sunrise,height=7pt]{\\strut}")
+ context("~~~")
+ context(srise)
+ context("\\quad")
+ context("\\SunA[background=Sunset,height=7pt]{\\strut}")
+ context("~~~")
+ context(sset)
+ context("~~")
+ context("\\SunB[background=Light,height=7pt]{\\strut}")
+ context("~~")
+ context(lhours)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ end}
+ context.strut()
+ context.page()
+end
+
+function diary.weekplan(weekday,weeknumber,month,year,lat,lon,
+ timeoffset,continent) --8 parameters
+
+ report("Working in function: diary.weekplan")
+
+ context.setupheadertexts{
+ function()
+ context.bTABLE({setups="table:topweekplan"})
+ context.bTR()
+ context.bTD()
+ context("\\bf")
+ context.labeltext("weekagenda")
+ context.eTD()
+ context.bTD()
+ context.labeltext("month")
+ context("~")
+ context(month)
+ context("\\quad")
+ context.labeltext("week")
+ context("~")
+ context(weeknumber)
+ context("\\quad")
+ context(year)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ end}
+ diary.thisweek(weeknumber,month,year,lat,lon,timeoffset,continent)
+ context.page()
+end
+
+function diary.nextweekplan(...)
+
+ local weekday, weeknumber, month, year, lat, lon, timeoffset, dst_start,
+ dst_stop, dayofmonth, dayname, holiday, monthname, moondata, srise, sset,
+ lhours = diary.data(...)
+
+ report("Working in function: diary.nextweekplan")
+
+ context.setupheadertexts{
+ function()
+ context.bTABLE({setups="table:topinfo"})
+ context.bTR()
+ context.bTD()
+ context("\\bf\\labeltext{weekagenda}")
+ context.eTD()
+ context.bTD()
+ context.strut()
+ context.eTD()
+ context.bTD()
+ context.labeltext("week")
+ context("~")
+ context(weeknumber)
+ context("\\quad")
+ context(year)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ end}
+ diary.thisweek(weeknumber,month,year,lat,lon,timeoffset,continent)
+ context.page()
+end
+
+function diary.weekendplan(weekday,weeknumber,month,year,lat,
+ lon,timeoffset,continent)
+
+ local weekday, weeknumber, month, year, lat, lon, timeoffset, dst_start,
+ dst_stop, dayofmonth, dayname, holiday, monthname, moondata, srise,
+ sset, lhours =
+ diary.data(weekday,weeknumber,month,year,lat,lon,timeoffset,continent)
+
+ report(" Working in function: diary.weekendplan")
+
+ context.setupheadertexts{
+ function()
+ context.bTABLE({setups="table:topinfo"})
+ context.bTR()
+ context.bTD()
+ context(dayofmonth)
+ context("~")
+ context.labeltext(dayname)
+ context.eTD()
+ context.bTD()
+ context.labeltext(holiday)
+ context.eTD()
+ context.bTD()
+ context.labeltext(monthname)
+ context("~")
+ context(year)
+ context.eTD()
+ context.eTR()
+ context.bTR({style="\\switchtobodyfont[5pt]"})
+ context.bTD()
+ if tonumber(moondata) then
+ context.labeltext("moondays")
+ else
+ context.labeltext("moon")
+ end
+ context(": ")
+ context(moondata)
+ context.eTD()
+ context.bTD({nx="2"})
+ context.dontleavehmode()
+ context("\\SunA[background=Sunrise,height=7pt]{\\strut}")
+ context("~~~:~")
+ context(srise)
+ context("\\quad")
+ context("\\SunA[background=Sunset,height=7pt]{\\strut}")
+ context("~~~")
+ context(sset)
+ context("~~")
+ context("\\SunB[background=Light,height=7pt]{\\strut}")
+ context("~~")
+ context(lhours)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ end}
+
+ local wday = 7
+ local weekday, weeknumber, month, year, lat, lon, timeoffset, dst_start,
+ dst_stop, dayofmonth, dayname, holiday, onthname,moondata,srise,sset,
+ lhours = diary.data(wday, weeknumber, month, year, lat, lon, timeoffset,
+ continent)
+
+ -- report("Working in function: diary.weekendplan: Sunday"
+
+ context.strut()
+ context("\\godown[.4\\textheight]")
+ context.bTABLE({setups="table:topinfo"})
+ context.bTR()
+ context.bTD()
+ context.color({"red"},
+ function() context(dayofmonth) end)
+ context("~")
+ context.color({"red"},
+ function() context.labeltext(dayname) end)
+ context.eTD()
+ context.bTD()
+ context.labeltext(holiday)
+ context.eTD()
+ context.bTD()
+ context.labeltext(monthname)
+ context("~")
+ context(year)
+ context.eTD()
+ context.eTR()
+ context.bTR({style="\\switchtobodyfont[5pt]"})
+ context.bTD()
+ if tonumber(moondata) then
+ context.labeltext("moondays")
+ else
+ context.labeltext("moon")
+ end
+ context(": ")
+ context(moondata)
+ context.eTD()
+ context.bTD({nx="2"})
+ context.dontleavehmode()
+ context("\\SunA[background=Sunrise,height=7pt]{\\strut}")
+ context("~~~~")
+ context(srise)
+ context("\\quad")
+ context("\\SunA[background=Sunset,height=7pt]{\\strut}")
+ context("~~~")
+ context(sset)
+ context("~~")
+ context("\\SunB[background=Light,height=7pt]{\\strut}")
+ context("~~")
+ context(lhours)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ context.par()
+ context("\\godown[3pt]")
+ context.blackrule({"color=\\getvariable{PocketDiaryColors}{Separatorline},height=0.5pt,width=\\textwidth"})
+ context.page()
+end
+
+function diary.monthcurrentplan(mon,y)
+ local month = mon
+ local year = y
+
+ report("Working in function: diary.monthcurrentplan")
+
+ local month_name = thirddata.calendar.select_nameofmonth(month,year)
+
+ context.setupheadertexts{
+ function()
+ context.bTABLE({setups="table:topweekplan"})
+ context.bTR()
+ context.bTD()
+ context.labeltext(month_name)
+ context.eTD()
+ context.bTD()
+ context(year)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ end}
+
+ diary.monthtableH(month,year)
+ context.page()
+end
+
+function diary.monthnextplan(mn,yr)
+
+ report("Working in function: diary.monthnextplan")
+
+ local month = mn
+ local year = yr
+
+ month = month + 1
+
+ if month > 12 then
+ month = 1
+ year = year + 1
+ end
+
+ local month_name = thirddata.calendar.select_nameofmonth(month,year)
+
+ context.setupheadertexts{
+ function()
+ context.bTABLE({setups="table:topweekplan"})
+ context.bTR()
+ context.bTD()
+ context.labeltext(month_name)
+ context.eTD()
+ context.bTD()
+ context(year)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ end}
+
+ diary.monthtableH(month,year)
+ context.page()
+end
+
+function diary.yearplan(yr,nxt)
+
+ report("Working in function: diary.yearplan")
+
+ local year = yr
+ local next = nxt
+
+ if next == "yes" then
+ year = year + 1
+ end
+
+ context.setupheadertexts{
+ function()
+ context.bTABLE({setups="table:topinfo"})
+ context.bTR()
+ context.bTD()
+ context(year)
+ context.eTD()
+ context.bTD()
+ context.strut()
+ context.eTD()
+ context.bTD()
+ context.strut()
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ end}
+ context.start()
+ context.switchtobodyfont({"4pt"})
+ diary.yearcalendar(year)
+ context.stop()
+ context.page()
+end
+
+function diary.daybydayplan(weekday,weeknumber,month,year,lat,lon,
+ timeoffset,continent) --8 parameters
+
+ report("Working in function: diary.daybyday")
+
+ --Working days
+ for i = 1,5 do
+
+ thirddata.diary.dayplan(i,weeknumber,month,year,lat,lon,
+ timeoffset, continent)
+ end
+
+ -- Weekend
+ thirddata.diary.weekendplan(6, weeknumber,month,year,lat,lon,
+ timeoffset, continent)
+ context.page()
+end
+
+-- Generate a Context table containing the days of a given month,
+-- topline weeknumber
+
+function diary.monthtableH(mn,yr)
+ local month = mn
+ local year = yr
+
+ report("Working in function: diary.monthtableH")
+
+ if month > 12 then
+ month = month - 12
+ year = year + 1
+ end
+
+ context.bTABLE({setups="table:month"})
+ context.bTR()
+
+ local w = {"mon","tue","wed","thu","fri","sat","sun"}
+ for a,d in ipairs(w) do
+ context.bTD({align="middle,lohi"})
+ context.labeltext(d)
+ context.eTD()
+ end
+
+ context.eTR()
+
+ ----returns number of weeks in a given month
+
+ local c = thirddata.calendar.month(month,year)
+
+ for i = 1, c do
+ context.bTR()
+ for j=(i-1)*7+1,(i-1)*7+7 do
+ local day = thirddata.calendar.dayselectofmonth(j)
+ local holiday
+ if day ~= "" then
+ holiday = thirddata.calendar.checkchristianfeast(
+ day,month,year)
+ end
+
+ context.bTD()
+
+ if holiday ~= "" then
+ context.color({"red"},
+ function() context(day) end)
+ else
+ context(day)
+ end
+
+ context.eTD()
+ end
+ context.eTR()
+ end
+
+ context.eTABLE()
+end
+
+-- Generate a Context table containing the days of a given month, topline
+-- weekday names
+
+function diary.monthtableV(month,year)
+
+ report("Working in function diary.monthtableV")
+
+ local c = thirddata.calendar.month(month,year) --returns number of weeks in a given month
+ local wkf = thirddata.calendar.weeknumber(1,month,year)
+
+ local nofdays = 1
+
+ if month == 2 and thirddata.calendar.isleapyear(year) ~= 365 then
+ nofdays = thirddata.calendar.nofdays_month(month,year) + 1
+ else
+ nofdays = thirddata.calendar.nofdays_month(month,year)
+ end
+
+ local wkl = thirddata.calendar.weeknumber(nofdays,month,year)
+
+ context.bTABLE({setups="table:year"})
+ context.bTR({align="flushright"})
+ context.bTD()
+ context.strut()
+ context.eTD()
+
+ if month == 1 and wkf > 51 then
+ context.bTD()
+ context(wkf)
+ context.eTD()
+ wkf = 1
+ for i = wkf, c - 1 do
+ context.bTD()
+ context(i)
+ context.eTD()
+ end
+ else
+ for i = wkf, wkf + c - 1 do
+ context.bTD()
+ context(i)
+ context.eTD()
+ end
+ end
+ context.eTR()
+
+ local w = {"mon","tue","wed","thu","fri","sat","sun"}
+ local row = 0
+
+ for a,d in ipairs(w) do
+ if a == 7 then
+ context.bTR({align="flushright",style="red"})
+ else
+ context.bTR({align="flushright"})
+ end
+
+ context.bTD({align="flushleft"})
+ context.labeltext(d)
+ context.eTD()
+
+ for i=1,c*7,7 do
+ local day = i + row
+ local dayofmonth = thirddata.calendar.dayselectofmonth(day)
+
+ --report("Day of month in monthtableV: %s",dayofmonth)
+ local holiday
+
+ if dayofmonth ~= "" then
+ holiday = thirddata.calendar.checkchristianfeast(
+ dayofmonth,month,year)
+ end
+
+ context.bTD()
+
+ if holiday ~= "" then
+ context.color({"red"},
+ function() context(dayofmonth) end)
+ else
+ context(dayofmonth)
+ end
+ context.eTD()
+ end
+ row = row + 1
+ context.eTR()
+ end
+ context.eTABLE()
+end
+
+function diary.yearcalendar(year)
+
+ report("Working in function: diary.year")
+
+ context.startcombination({"4*3"})
+ for i= 1,12 do
+ local monthname = string.lower(os.date(
+ "%B",os.time{year=year,month=i,day=1}))
+ context.framedtext({frame="off",
+ style="bold",
+ width=number.todimen(0.23*tex.dimen.textwidth),
+ offset="0.5pt",
+ align="middle"},
+ function() context.labeltext(monthname) end,
+ function() diary.monthtableV(i,year) end
+ )
+ end
+ context.stopcombination()
+end
+
+function diary.thisweek(wk,mn,yr,lat,lon,timeoffset,continent)
+
+ report("Working in function: diary.thisweek")
+ --report("Year %d", yr)
+ --report("weeknumber in diary.thisweek %s",wk)
+
+
+ local weeknumber = wk
+ local year = yr
+ local month = mn
+
+ local mondaytimestamp = thirddata.calendar.weekcalendar(weeknumber,month,year)
+
+ --report("Month based on mondaytimestamp: %s", m)
+ local d = tonumber(os.date("%d",mondaytimestamp)) -- day part of date
+
+ -- The following line will be deleted if it works
+ local y = tonumber(os.date("%Y",mondaytimestamp))
+ --report("Year: %d",y)
+
+ --report("Now in diary.thisweek at day %s",d)
+
+ diary.weektable(mondaytimestamp,month,year,
+ lat,lon,timeoffset,continent)
+end
+
+function diary.nextweek(wk,mn,year,lat,lon,timeoffset,dst_start,dst_stop)
+
+ report("Working in function: diary.nextweek")
+
+ local weeknumber = wk + 1
+ local mondaytimestamp = thirddata.calendar.weekcalendar(weeknumber,mn,year)
+
+ diary.weektable(mondaytimestamp,mn,year,
+ lat,lon,timeoffset,continent)
+end
+
+function diary.weektable(mondaytimestamp,mn,year,
+ lat,lon,timeoffset,continent)
+ local year = year
+ local s = mondaytimestamp
+ local dst_start,dst_stop = diary.DST(year,continent)
+
+ report("Working in function: diary.weektable")
+ local x = os.date("%x",mondaytimestamp)
+
+ --report("Actual date: %s",x)
+
+ context.bTABLE({setups="table:week"})
+
+ local yeardays = thirddata.calendar.isleapyear(year) -- returns 365 or 366
+
+ for i = 1,5 do
+ local daystamp = s + i * 24 * 60 * 60
+ local d = tonumber(os.date("%d",daystamp)) -- day part of date
+
+ --report("Year in week-loop: %d",year)
+ --report("Day in week-loop: %s",d)
+
+ local n = string.lower(os.date("%a",daystamp)) -- day name
+
+ --report("Day name in week loop: %s",n)
+
+ local m = tonumber(os.date("%m",daystamp)) -- month number
+
+ --report("Month number in week-loop %d",m)
+
+ local f = thirddata.calendar.checkchristianfeast(d,m,year)
+ local t = os.date("*t",os.time{year=year,month=m,day=d}) -- This returns a table!
+ local moondata = thirddata.moonphase.lunardays(year,m,d)
+
+ if not f then
+ f = ""
+ end
+
+ context.bTR()
+ context.bTD({nx=2})
+ if f ~= "" and f ~= "ashw" then
+ context.color({"red"},
+ function() context(d) end)
+ context("~")
+ context.color({"red"},
+ function() context.labeltext(n) end)
+ else
+ context(d)
+ context("~")
+ context.labeltext(n)
+ end
+ context.bgroup()
+ context.switchtobodyfont({"6pt"})
+ context("~")
+ context(t.yday)
+ context("/")
+ context(yeardays)
+
+ if not tonumber(moondata) then
+ context("~")
+ context(moondata)
+ end
+
+ if n == "tue" then
+ local srise,sset,lhours =
+ thirddata.srss.sundata(d,m,year,lat,lon,
+ timeoffset,dst_start,dst_stop)
+ --report("Sun data %s,%s,%s", srise,sset,lhours)
+ context("\\quad")
+ context("\\SunA[background=Sunrise,height=7pt]{\\strut}")
+ context("\\quad ~")
+ context(srise)
+ context("~~~")
+ context("\\SunA[background=Sunset,height=7pt]{\\strut}")
+ context("\\quad ~")
+ context(sset)
+ context("~~~")
+ context("\\SunB[background=Light,height=7pt]{\\strut}")
+ context("~~")
+ context(lhours)
+ end
+ context.egroup()
+ context("~")
+ context.labeltext(f)
+ context.eTD()
+ context.eTR()
+ end
+
+ context.bTR()
+ local daystamp = s + 6 * 24 * 60 * 60
+ local d = tonumber(os.date("%d",daystamp))
+ local n = string.lower(os.date("%a",daystamp))
+ local m = tonumber(os.date("%m",daystamp))
+ local f = thirddata.calendar.checkchristianfeast(d,m,year)
+ local t = os.date("*t",os.time{year=year,month=m,day=d}) -- This returns a table!
+
+ --report("Weekend day in loop: %s",d)
+
+ if not f then
+ f = ""
+ end
+
+ context.bTD()
+ if f ~= "" then
+ context.color({"red"},
+ function() context(d) end)
+ context("~")
+ context.color({"red"},
+ function() context.labeltext(n) end)
+ else
+ context(d)
+ context("~")
+ context.labeltext(n)
+ end
+ context.bgroup()
+ context("\\tfxx")
+ context("~")
+ context(t.yday)
+ context("/")
+ context(yeardays)
+ context.egroup()
+ context("~")
+ context.labeltext(f)
+ context.eTD()
+
+ local daystamp = s + 7 * 24 * 60 * 60
+ local d = tonumber(os.date("%d",daystamp))
+ local n = string.lower(os.date("%a",daystamp))
+ local m = tonumber(os.date("%m",daystamp))
+ local f = thirddata.calendar.checkchristianfeast(d,m,year)
+ local t = os.date("*t",os.time{year=year,month=m,day=d}) -- This returns a table!
+ --report("Weekend day in loop: %s",d)
+ if not f then
+ f = ""
+ end
+
+ context.bTD()
+ context.color({"red"},
+ function() context(d) end)
+ context("~")
+ context.color({"red"},
+ function() context.labeltext(n) end)
+ context.bgroup()
+ context("\\tfxx")
+ context("~")
+ context(t.yday)
+ context("/")
+ context(yeardays)
+ context.egroup()
+ context("~")
+ context.labeltext(f)
+ context.eTD()
+ context.eTR()
+ context.eTABLE()
+ context.page()
+end
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.mkiv
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.mkiv (rev 0)
+++ trunk/Master/texmf-dist/tex/context/third/pocketdiary/t-pocketdiary.mkiv 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,1507 @@
+%D \module
+%D [ file=t-pocketdiary,
+%D version="2023-04-15",
+%D title=PocketDiary \CONTEXT\ User Module,
+%D subtitle=PocketDiary,
+%D author=Willi Egger,
+%D date=\currentdate,
+%D copyright=Willi Egger,
+%D email=w.egger at boede.nl,
+%D license=Public Domain]
+
+\startmodule[pocketdiary]
+
+\writestatus{loading}{ConTeXt User Module / PocketDiary}
+
+%D \startsubject[title={Introduction}]
+%D
+%D It is already some time ago, that my brother Heinz asked me to prepare him a
+%D special page-arrangement scheme.
+%D This scheme is suitable to form a section with a single-sided printed sheet
+%D of paper.
+%D He wanted to use it for special kind of greeting-cards. By coincidence I
+%D detected an article by U. Ziegenhagen in de \TEX nische
+%D Kommödie nr. 3/2010. This article deals with the preparation of a PocketMod,
+%D which is a personal organizer
+%D based on the mentioned arranging scheme. In the article there is also a
+%D link mentioned to an online
+%D version of the PocketMod. (http://www.pocketmod.com/).
+%D -- After reading the article and visiting the web-site I got
+%D intrigued by the fact, that \CONTEXT\ has built in arranging capabilities
+%D and
+%D due to the \LUATEX\ engine and herewith the possibility to perform
+%D calculations in Lua it
+%D should be possible to build such a personal organizer in \CONTEXT.
+%D
+%D The result is contained in this module. I would like to thank Hans Hagen
+%D and Taco Hoekwater for the great
+%D \LUATEX\ machinery and Wolfgang Schuster for supporting me in tackling
+%D the multi-lingual interface.
+%D
+%D After the first version in 2011, we are now 11 years older, a lot
+%D has changed in and around the \CONTEXT
+%D -machinery. We are now using \LMTX\ (\LUAMETATEX ) the latest development.
+%D
+%D During the \CONTEXT -meeting 2021 Thomáš Hála presented his solution
+%D for generating an agenda, while the shops were closed during the Covid-19
+%D pandemic. Discussing issues with calendars revealed, that it could be
+%D interesting to integrate into a calendar also data concerning the moon
+%D phase and possibly information on the sun rise and sun set time.
+%D
+%D I thought, that I would like to do such calculations and give it a try.
+%D After having found information how to perform such astronomical
+%D calculations, slowly two new modules appeared. The calculations of the
+%D moon phases is quite straight forward and this can be considered the
+%D easy part of the new development. The only remark must be made, that
+%D those calculations are not super accurate. A deviation of about 1 day has
+%D to be accepted.
+%D
+%D Finding a way to calculate the sun rise and sun set times is much more
+%D tedious. Collecting articles on such calculations and building the
+%D formulas in Lua is not the issue, but that the given information in those
+%D articles looks
+%D incomplete for a layman like me. -- Finally I found a Lua-module written for
+%D an
+%D application for presenting the required data on screen (the reference
+%D to the authors is given in the Lua-file for the sun data calculations).
+%D I adapted
+%D this to Lua/\CONTEXT\ and it looks like it works fine. -- I have a Raspberry
+%D Pi Nano with a screen attached where I display weather information together
+%D with the sun data, which are fetched from the Open Weather Map
+%D (https://openweathermap.org). Due to the fact that the development of the
+%D solar data module took a long time I was able to compare the calculated
+%D results with those displayed on the Raspberry Pi screen. Happily they are
+%D completely congruent.
+%D
+%D \blank[big]
+%D
+%D Without the help of Hans Hagen, this module would not have been finished. I
+%D would like to thank him for all the support and patience with my struggles!
+%D \stopsubject
+
+%D \startsubject[title={Subpaths}]
+
+%D In order to keep the hole module clearly organized the moon phase
+%D as well as the sun rise/set calculation files are situated in
+%D separate folders.
+%D We tell \CONTEXT\ where to find the requested files
+
+\usepath[{Moonphase,Solar}]
+
+%D \stopsubject
+
+%D \startsubject[title={Lua-files}]
+%D All calculations for dates are performed with Lua functions.
+%D The functions are contained in \type{t-calendar.lua}
+
+%\ctxloadluafile{t-calendar}{}
+\ctxloadluafile{t-calendar}{}
+
+%D The calculations for the moon phase are done by Lua functions.
+%D The functions are contained in \type{t-moonphase.lua}
+%D in the folder \quotation{Moonphase}
+
+\ctxloadluafile{t-moonphase}{}
+
+%D The calculations for the sun rise and set time are calculated in Lua too.
+%D The
+%D functions are contained in the file \type{t-solar.lua} in the folder
+%D \quotation{Solar}
+
+\ctxloadluafile{t-solar}{}
+%D \stopsubject
+
+%D \startsubject[title={International interface}]
+%D
+%D The PocketDiary is aware of different languages. The language to be used is
+%D selected with \type{\mainlanguage[en]}. The following interfaces
+%D are available
+%D
+%D \startitemize[2,packed]
+%D \item Englisch interface
+%D \item Dutch interface
+%D \item German interface
+%D \item Italian interface
+%D \item French interface
+%D \item Spanish interface
+%D \item Polish interface
+%D \stopitemize
+%D \stopsubject
+
+%D English interface
+\setuplabeltext[en][calendar=Calendar]
+\setuplabeltext[en][weekagenda=Week calendar]
+\setuplabeltext[en][week=Week]
+\setuplabeltext[en][month=Month]
+\setuplabeltext[en][contact=Contact]
+\setuplabeltext[en][name=Name]
+\setuplabeltext[en][address=Address]
+\setuplabeltext[en][zip=Zip]
+\setuplabeltext[en][place=Place]
+\setuplabeltext[en][country=Country]
+\setuplabeltext[en][phone=Phone]
+\setuplabeltext[en][mail=e-mail]
+\setuplabeltext[en][notes=Notes]
+\setuplabeltext[en][todo=Todo]
+\setuplabeltext[en][found={If found\textcomma\ please return to:}]
+
+\setuplabeltext[en][nyd={New Year's Day}]
+\setuplabeltext[en][epi={Epiphany}]
+\setuplabeltext[en][ashw={Ash Wednesday}]
+\setuplabeltext[en][palms={Palm Sunday} ]
+\setuplabeltext[en][gfri={Good Friday} ]
+\setuplabeltext[en][esun={Easter Sunday}]
+\setuplabeltext[en][esmo={Easter Monday}]
+\setuplabeltext[en][ascd={Ascension Day}]
+\setuplabeltext[en][pcst=Pentecost]
+\setuplabeltext[en][pcstmo={Pentecost Monday}]
+\setuplabeltext[en][xmas=Christmas]
+\setuplabeltext[en][bxd={Boxing Day}]
+\setuplabeltext[en][day=Day]
+\setuplabeltext[en][mon=Mon]
+\setuplabeltext[en][tue=Tue]
+\setuplabeltext[en][wed=Wed]
+\setuplabeltext[en][thu=Thu]
+\setuplabeltext[en][fri=Fri]
+\setuplabeltext[en][sat=Sat]
+\setuplabeltext[en][sun=Sun]
+
+\setuplabeltext[en][january=January]
+\setuplabeltext[en][february=February]
+\setuplabeltext[en][march=March]
+\setuplabeltext[en][april=April]
+\setuplabeltext[en][may=May]
+\setuplabeltext[en][june=June]
+\setuplabeltext[en][july=July]
+\setuplabeltext[en][august=August]
+\setuplabeltext[en][september=September]
+\setuplabeltext[en][october=October]
+\setuplabeltext[en][november=November]
+\setuplabeltext[en][december=December]
+
+\setuplabeltext[en][moondays=Lunar days]
+\setuplabeltext[en][moon=Moon]
+\setuplabeltext[en][sunrise=Sunrise]
+\setuplabeltext[en][sunset=Sunset]
+\setuplabeltext[en][lighthours=Lighthours]
+\setuplabeltext[en][sunstar=Sun]
+
+%D German interface
+\setuplabeltext[de][calendar=Planer] % Terminkalender, Kalender
+\setuplabeltext[de][weekagenda=Wochenagenda]
+\setuplabeltext[de][week=Woche]
+\setuplabeltext[de][month=Monat]
+\setuplabeltext[de][contact=Kontakt]
+\setuplabeltext[de][name=Name]
+\setuplabeltext[de][address=Adresse]
+\setuplabeltext[de][zip=Postleitzahl]
+\setuplabeltext[de][place=Ort]
+\setuplabeltext[de][country=Land]
+\setuplabeltext[de][phone=Telefon]
+\setuplabeltext[de][mail=e-Mail]
+\setuplabeltext[de][notes=Notizen]
+\setuplabeltext[de][todo={Zu erledigen}]
+\setuplabeltext[de][found={Wenn gefunden\textcomma\ bitte retournieren an:}]
+
+\setuplabeltext[de][nyd=Neujahr]
+\setuplabeltext[de][epi=Dreikönigstag]
+\setuplabeltext[de][ashw=Aschermittwoch]
+\setuplabeltext[de][palms=Palmsonntag]
+\setuplabeltext[de][gfri=Karfreitag]
+\setuplabeltext[de][esun=Ostern]
+\setuplabeltext[de][esmo=Ostermontag]
+\setuplabeltext[de][ascd=Himmelfahrt]
+\setuplabeltext[de][pcst=Pfingsten]
+\setuplabeltext[de][pcstmo=Pfingstmontag]
+\setuplabeltext[de][xmas=Weihnachten]
+\setuplabeltext[de][bxd=Stephanstag]
+\setuplabeltext[de][day=Tag]
+\setuplabeltext[de][mon=Mo]
+\setuplabeltext[de][tue=Di]
+\setuplabeltext[de][wed=Mi]
+\setuplabeltext[de][thu=Do]
+\setuplabeltext[de][fri=Fr]
+\setuplabeltext[de][sat=Sa]
+\setuplabeltext[de][sun=So]
+
+\setuplabeltext[de][january=Januar]
+\setuplabeltext[de][february=Februar]
+\setuplabeltext[de][march=März]
+\setuplabeltext[de][april=April]
+\setuplabeltext[de][may=Mai]
+\setuplabeltext[de][june=Juni]
+\setuplabeltext[de][july=Juli]
+\setuplabeltext[de][august=August]
+\setuplabeltext[de][september=September]
+\setuplabeltext[de][october=Oktober]
+\setuplabeltext[de][november=November]
+\setuplabeltext[de][december=Dezember]
+
+\setuplabeltext[de][moondays=Mondtage]
+\setuplabeltext[de][moon=Mond]
+\setuplabeltext[de][sunrise=Sonnenaufgang]
+\setuplabeltext[de][sunset=Sonnenuntergang]
+\setuplabeltext[de][lighthours=Taglichtstunden]
+\setuplabeltext[de][sunstar=Sonne]
+
+%D Dutch interface
+\setuplabeltext[nl][calendar=Kalender]
+\setuplabeltext[nl][weekagenda=Weekagenda]
+\setuplabeltext[nl][week=Week]
+\setuplabeltext[nl][month=Maand]
+\setuplabeltext[nl][contact=Kontakt]
+\setuplabeltext[nl][name=Naam]
+\setuplabeltext[nl][address=Adres]
+\setuplabeltext[nl][zip=Postcode]
+\setuplabeltext[nl][place=Plaats]
+\setuplabeltext[nl][country=Land]
+\setuplabeltext[nl][phone=Tel.]
+\setuplabeltext[nl][mail=e-mail]
+\setuplabeltext[nl][notes=Notities]
+\setuplabeltext[nl][todo=Todo]
+\setuplabeltext[nl][found={Wanneer gevonden\textcomma\ aub sturen naar:}]
+
+\setuplabeltext[nl][nyd={Nieuw jaar}]
+\setuplabeltext[nl][epi=Driekoningen]
+\setuplabeltext[nl][ashw=Aswoensdag]
+\setuplabeltext[nl][palms=Palmpasen]
+\setuplabeltext[nl][gfri={Goede vrijdag}]
+\setuplabeltext[nl][esun=Pasen]
+\setuplabeltext[nl][esmo={2\high{de} Paasdag}]
+\setuplabeltext[nl][ascd=Hemelvaart]
+\setuplabeltext[nl][pcst=Pinksteren]
+\setuplabeltext[nl][pcstmo={2\high{de} Pinksterdag}]
+\setuplabeltext[nl][xmas=Kerst]
+\setuplabeltext[nl][bxd={2\high{de} Kerstdag}]
+\setuplabeltext[nl][day=Dag]
+\setuplabeltext[nl][mon=Ma]
+\setuplabeltext[nl][tue=Di]
+\setuplabeltext[nl][wed=Woe]
+\setuplabeltext[nl][thu=Do]
+\setuplabeltext[nl][fri=Fr]
+\setuplabeltext[nl][sat=Za]
+\setuplabeltext[nl][sun=Zo]
+
+\setuplabeltext[nl][january=Januari]
+\setuplabeltext[nl][february=Febrari]
+\setuplabeltext[nl][march=Maart]
+\setuplabeltext[nl][april=April]
+\setuplabeltext[nl][may=Mei]
+\setuplabeltext[nl][june=Juni]
+\setuplabeltext[nl][july=Juli]
+\setuplabeltext[nl][august=Augustus]
+\setuplabeltext[nl][september=September]
+\setuplabeltext[nl][october=October]
+\setuplabeltext[nl][november=November]
+\setuplabeltext[nl][december=December]
+
+\setuplabeltext[nl][moondays=Maandagen]
+\setuplabeltext[nl][moon=Maan]
+\setuplabeltext[nl][sunrise=Zonsopg.]
+\setuplabeltext[nl][sunset=Zonsonderg.]
+\setuplabeltext[nl][lighthours=Lichturen]
+\setuplabeltext[nl][sunstar=Zon]
+
+%D French interface
+\setuplabeltext[fr][calendar=Calendrier]
+\setuplabeltext[fr][weekagenda={Cal. de la semaine}]
+\setuplabeltext[fr][week=Sem.]
+\setuplabeltext[fr][month=Mois]
+\setuplabeltext[fr][contact=Contact]
+\setuplabeltext[fr][name=Nom]
+\setuplabeltext[fr][address=Adresse]
+\setuplabeltext[fr][zip=CP]
+\setuplabeltext[fr][place=Lieu]
+\setuplabeltext[fr][country=Pays]
+\setuplabeltext[fr][phone=Tél.]
+\setuplabeltext[fr][mail=e-mail]
+\setuplabeltext[fr][notes=Observations]
+\setuplabeltext[fr][todo=Tâches]
+\setuplabeltext[fr][found={Si trouvé\textcomma\ retourner s.v.p. à: }]
+
+\setuplabeltext[fr][nyd={Jour de l'an}]
+\setuplabeltext[fr][epi={Épiphany}]
+\setuplabeltext[fr][ashw={Mercredi des Cendres}]
+\setuplabeltext[fr][palms={Dimanche des Rameaux}]
+\setuplabeltext[fr][gfri={Vendredi saint}]
+\setuplabeltext[fr][esun={Pâques}]
+\setuplabeltext[fr][esmo={Lundi de Pâques}]
+\setuplabeltext[fr][ascd={Jour de l'ascension}]
+\setuplabeltext[fr][pcst=Pentecôte]
+\setuplabeltext[fr][pcstmo={Lundi de Pentecôte}]
+\setuplabeltext[fr][xmas=Noël]
+\setuplabeltext[fr][bxd=]
+\setuplabeltext[fr][day=Jour]
+\setuplabeltext[fr][mon=Lun]
+\setuplabeltext[fr][tue=Mar]
+\setuplabeltext[fr][wed=Mer]
+\setuplabeltext[fr][thu=Jeu]
+\setuplabeltext[fr][fri=Ven]
+\setuplabeltext[fr][sat=Sam]
+\setuplabeltext[fr][sun=Dim]
+
+\setuplabeltext[fr][january=Janvier]
+\setuplabeltext[fr][february=Février]
+\setuplabeltext[fr][march=Mars]
+\setuplabeltext[fr][april=Avril]
+\setuplabeltext[fr][may=Mai]
+\setuplabeltext[fr][june=Juin]
+\setuplabeltext[fr][july=Juillet]
+\setuplabeltext[fr][august=Août]
+\setuplabeltext[fr][september=Septembre]
+\setuplabeltext[fr][october=Octobre]
+\setuplabeltext[fr][november=Novembre]
+\setuplabeltext[fr][december=Décembre]
+
+\setuplabeltext[fr][moondays=Jours lun.] % jours lunaires
+\setuplabeltext[fr][moon=Lune]
+\setuplabeltext[fr][sunrise=Lever du s.] %soleil
+\setuplabeltext[fr][sunset=Coucher du s.] %soleil
+\setuplabeltext[fr][lighthours=Heures de l.] %lumière
+\setuplabeltext[fr][sunstar=Soleil]
+
+% Italian interface
+\setuplabeltext[it][calendar=Calendario]
+\setuplabeltext[it][weekagenda=Calendario di settimana]
+\setuplabeltext[it][week=Sett.] %Settimana
+\setuplabeltext[it][month=Mese]
+\setuplabeltext[it][contact=Contatto]
+\setuplabeltext[it][name=Nome]
+\setuplabeltext[it][address=Indirizzo]
+\setuplabeltext[it][zip=C.A.P.]
+\setuplabeltext[it][place=Luogo]
+\setuplabeltext[it][country=Paese]
+\setuplabeltext[it][phone=Tel.]
+\setuplabeltext[it][mail=e-mail]
+\setuplabeltext[it][notes=Osservazioni]
+\setuplabeltext[it][todo=Compiti]
+\setuplabeltext[it][found={Se trovato\textcomma\ prego speditelo à:}]
+
+%D Italian interface
+\setuplabeltext[it][nyd=Capodanno]
+\setuplabeltext[it][epi={Epifania}]
+\setuplabeltext[it][ashw={Giorno delle Ceneri}]
+\setuplabeltext[it][palms={Domenica delle Palme}]
+\setuplabeltext[it][gfri={Venerdi santo}]
+\setuplabeltext[it][esun=Pasqua]
+\setuplabeltext[it][esmo={Lunedì dell'Angelo}]
+\setuplabeltext[it][ascd=Ascensione]
+\setuplabeltext[it][pcst=Pentecoste]
+\setuplabeltext[it][pcstmo={Lunedì di Pentecoste}]
+\setuplabeltext[it][xmas=Natale]
+\setuplabeltext[it][bxd={Giorno di S. Stefano}]
+\setuplabeltext[it][day=Giorno]
+\setuplabeltext[it][mon=Lun]
+\setuplabeltext[it][tue=Mar]
+\setuplabeltext[it][wed=Mer]
+\setuplabeltext[it][thu=Gio]
+\setuplabeltext[it][fri=Ven]
+\setuplabeltext[it][sat=Sab]
+\setuplabeltext[it][sun=Dom]
+
+\setuplabeltext[it][january=Gennaio]
+\setuplabeltext[it][february=Febbraio]
+\setuplabeltext[it][march=Marzo]
+\setuplabeltext[it][april=Aprile]
+\setuplabeltext[it][may=Maggio]
+\setuplabeltext[it][june=Giugno]
+\setuplabeltext[it][july=Luglio]
+\setuplabeltext[it][august=Agosto]
+\setuplabeltext[it][september=Settembre]
+\setuplabeltext[it][october=Ottobre]
+\setuplabeltext[it][november=Novembre]
+\setuplabeltext[it][december=Dicembre]
+
+\setuplabeltext[it][moondays=Giorni lun.] %Giorni lunari
+\setuplabeltext[it][moon=Luna]
+\setuplabeltext[it][sunrise=Albo]
+\setuplabeltext[it][sunset=Tramonto]
+\setuplabeltext[it][lighthours={O. di luce}] %Ore di luce
+\setuplabeltext[it][sunstar=Sole]
+
+%D Spanish interface
+\setuplabeltext[es][calendar=Agenda]
+\setuplabeltext[es][weekagenda=Agenda semanal]
+\setuplabeltext[es][week=Sem.] %Semana
+\setuplabeltext[es][month=Mes]
+\setuplabeltext[es][contact=Contacto]
+\setuplabeltext[es][name=Nombre]
+\setuplabeltext[es][address=Dirección]
+\setuplabeltext[es][zip=C.P.]
+\setuplabeltext[es][place=Población]
+\setuplabeltext[es][country=País]
+\setuplabeltext[es][phone=Tel.]
+\setuplabeltext[es][mail=Correo-e]
+\setuplabeltext[es][notes=Observaciones]
+\setuplabeltext[es][todo=Pendiente]
+\setuplabeltext[es][found={Por favor\textcomma\ devuélvalo a:}]
+
+\setuplabeltext[es][nyd=Año Nuevo]
+\setuplabeltext[es][epi={Reyes Magos}]
+\setuplabeltext[es][ashw={Miércoles de Ceniza}]
+\setuplabeltext[es][palms={Domingo de Palmas}]
+\setuplabeltext[es][gfri={Viernes santo}]
+\setuplabeltext[es][esun=Domingo de Pascua]
+\setuplabeltext[es][esmo={Lunes de Pascua}]
+\setuplabeltext[es][ascd=Ascensión]
+\setuplabeltext[es][pcst=Pentecostes]
+\setuplabeltext[es][pcstmo={Lunes de Pentecostes}]
+\setuplabeltext[es][xmas=Navidad]
+\setuplabeltext[es][bxd={San Esteban}]
+\setuplabeltext[es][day=Día]
+\setuplabeltext[es][mon=Lu]
+\setuplabeltext[es][tue=Ma]
+\setuplabeltext[es][wed=Mi]
+\setuplabeltext[es][thu=Ju]
+\setuplabeltext[es][fri=Vi]
+\setuplabeltext[es][sat=Sá]
+\setuplabeltext[es][sun=Do]
+
+\setuplabeltext[es][january=Enero]
+\setuplabeltext[es][february=Febrero]
+\setuplabeltext[es][march=Marzo]
+\setuplabeltext[es][april=Abril]
+\setuplabeltext[es][may=Mayo]
+\setuplabeltext[es][june=Junio]
+\setuplabeltext[es][july=Julio]
+\setuplabeltext[es][august=Agosto]
+\setuplabeltext[es][september=Septiembre]
+\setuplabeltext[es][october=Octubre]
+\setuplabeltext[es][november=Noviembre]
+\setuplabeltext[es][december=Diciembre]
+
+\setuplabeltext[es][moondays=Días lunares]
+\setuplabeltext[es][moon=Luna]
+\setuplabeltext[es][sunrise=Alba]
+\setuplabeltext[es][sunset=Ocaso]
+\setuplabeltext[es][lighthours={Horas de luz}]
+\setuplabeltext[es][sunstar=Sol]
+
+%D Polish interface
+\setuplabeltext[pl][calendar=Kalendarz]
+\setuplabeltext[pl][weekagenda={Kalendarz tygodniowy}]
+\setuplabeltext[pl][week=Tydzień]
+\setuplabeltext[pl][month=Miesiąc]
+\setuplabeltext[pl][contact=Kontakt]
+\setuplabeltext[pl][name=Nazwisko]
+\setuplabeltext[pl][address=Adres]
+\setuplabeltext[pl][zip=Kod pocztowy]
+\setuplabeltext[pl][place=Miejsce zamieszkania]
+\setuplabeltext[pl][country=Kraj]
+\setuplabeltext[pl][phone=Telefon]
+\setuplabeltext[pl][mail=e-mail]
+\setuplabeltext[pl][notes=Notatki]
+\setuplabeltext[pl][todo=Do zrobienia]
+\setuplabeltext[pl][found={W przypadku znalezienia proszę o odesłanie na adres}]
+
+\setuplabeltext[pl][nyd={Nowy Rok}]
+\setuplabeltext[pl][epi={Trzech Króli}]
+\setuplabeltext[pl][ashw={Środa Popielcowa}]
+\setuplabeltext[pl][palms={Niedziela Palmowa} ]
+\setuplabeltext[pl][gfri={Wielki Piątek} ]
+\setuplabeltext[pl][esun={Niedziela Wielkanocna}]
+\setuplabeltext[pl][esmo={Pn. Wielkanocny}]
+\setuplabeltext[pl][ascd={Wniebowstąpienie}]
+\setuplabeltext[pl][pcst={Zesłanie Ducha Świętego}]
+\setuplabeltext[pl][pcstmo={}]
+\setuplabeltext[pl][xmas=Święta] %Święta Bożego Narodzenia .
+\setuplabeltext[pl][bxd={Drugi dzień świąt}]
+\setuplabeltext[pl][day=Dzień]
+\setuplabeltext[pl][mon=Pn.]
+\setuplabeltext[pl][tue=Wt.]
+\setuplabeltext[pl][wed=Śr.]
+\setuplabeltext[pl][thu=Czw.]
+\setuplabeltext[pl][fri=Pt.]
+\setuplabeltext[pl][sat=Sob.]
+\setuplabeltext[pl][sun=Ndz.]
+
+\setuplabeltext[pl][january=Styczeń]
+\setuplabeltext[pl][february=Luty]
+\setuplabeltext[pl][march=Marzec]
+\setuplabeltext[pl][april=Kwiecień]
+\setuplabeltext[pl][may=Maj]
+\setuplabeltext[pl][june=Czerwiec]
+\setuplabeltext[pl][july=Lipiec]
+\setuplabeltext[pl][august=Sierpień]
+\setuplabeltext[pl][september=Wrzesień]
+\setuplabeltext[pl][october=Październik]
+\setuplabeltext[pl][november=Listopad]
+\setuplabeltext[pl][december=Grudzień]
+
+\setuplabeltext[pl][moondays=Dzień lunarny]
+\setuplabeltext[pl][moon=Księżyc]
+\setuplabeltext[pl][sunrise={Wschód słońca}]
+\setuplabeltext[pl][sunset={Zachód słońca}]
+\setuplabeltext[pl][lighthours=Długość dnia]
+\setuplabeltext[pl][sunstar=Słońce]
+
+%D \startsubject[title={PocketDiary layout}]
+%D
+%D This module uses different page templates, whereof one uses a symbol
+%D out of the set 2 of the Martin Vogel collection. So we load these symbols:
+
+\usesymbols[mvs]
+\setupsymbolset[martinvogel 2]
+
+%D The placement of the page numbers is switched off for the moment.
+
+\setuppagenumbering[location=]
+
+%D Because we will place 8 pages on an A4 landscape, we define our own pagesize
+
+\definepapersize[Arrangingformat][width=7.42cm, height=10.5cm]
+\setuppapersize[Arrangingformat][A4,landscape]
+
+%D In the templates a light gray color for (grid)lines is used. Separator
+%D lines can have
+%D an individual color too. We define the two colors with arbitrary values.
+%D These preset colors can be adjusted in the user file \type{PocketDiary.tex}.
+
+\definecolor[Grid][s=.75]
+\definecolor[Separatorline][blue]
+
+%D The page of the PocketDiary has a fairly simple layout. We use a
+%D header- and a footer-space.
+%D The header has a rule beneath and the footer one on top.
+%D
+%D The preset body-font is Pagella at 10pt
+%D
+%D We will also use tabular figures throughout the typesetting:
+%D \stopsubject
+
+\setuplayout
+ [topspace=.6cm,
+ backspace=.6cm,
+ header=3\bodyfontsize,
+ headerdistance=.5\bodyfontsize,
+ footer=1.2\bodyfontsize,
+ footerdistance=.5\bodyfontsize,
+ margin=0pt,
+ height=middle,
+ width=middle]
+
+\setupbackgrounds
+ [header]
+ [text]
+ [state=repeat,
+ frame=off,
+ bottomframe=on,
+ framecolor=\getvariable{PocketDiaryColors}{Separatorline}]
+
+\setupbackgrounds
+ [footer]
+ [text]
+ [state=repeat,
+ frame=off,
+ topframe=on,
+ framecolor=\getvariable{PocketDiaryColors}{Separatorline}]
+
+\setupbodyfont[pagella,rm,10pt]
+\definefontfeature[f:tabular] [tnum=yes]
+\definefontfeature[f:smallcaps][smcp=yes]
+
+\addfeature[f:tabular]
+
+%D \startsubject[title={\METAFUN\ drawings}]
+%D
+%D There are three templates which are made up in \METAPOST. The drawings are
+%D used as backgrounds to the typesetting area in the form of an overlay. So the
+%D drawings adapt themselves to the actual dimensions
+%D \stopsubject
+
+\startuniqueMPgraphic{Caro}
+ numeric w; w:= floor(OverlayWidth/4mm);
+ numeric h; h:= floor((OverlayHeight)/4mm);
+ path p,q;
+ p := unitsquare xscaled (4mm*w) yscaled (4mm*h);
+ q:= ulcorner p -- llcorner p;
+ for i = 0 upto w :
+ draw q shifted (i*4mm,0) withpen pencircle scaled .5pt
+ withcolor \MPcolor{Grid};
+ endfor;
+ q:= llcorner p -- lrcorner p;
+ for i = 0 upto h :
+ draw q shifted (0,i*4mm) withpen pencircle scaled .5pt
+ withcolor \MPcolor{Grid};
+ endfor;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{Lines}
+ numeric w; w:= OverlaytWidth;
+ numeric h; h:= floor(OverlayHeight/7mm);
+ path p,q;
+ p := unitsquare xscaled OverlayWidth yscaled (7mm*(h-1));
+ q:= llcorner p -- lrcorner p;
+ for i = 1 upto (h-1) :
+ draw q shifted (0,i*7mm) withpen pencircle scaled .5pt
+ withcolor \MPcolor{Grid};
+ endfor;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{Todo}
+ numeric w; w:= OverlayWidth;
+ numeric h; h:= floor(OverlayHeight/8mm);
+ path p,q;
+ p := unitsquare xscaled OverlayWidth yscaled OverlayHeight;
+ q:= llcorner p -- lrcorner p;
+ for i = 0 upto h :
+ draw q shifted (0,i*7mm) withpen pencircle scaled .5pt
+ withcolor \MPcolor{Grid};
+ label.top(textext("\tfd \symbol[HollowBox]"), point 0 of q
+ shifted (2mm,i*7mm));
+ endfor;
+\stopuniqueMPgraphic
+
+%D \startsubject[title={The moon phase}]
+%D
+%D The moon phase calculation from SubsySTEMs, an American education institute,
+%D for this module is based on a simple calculation.
+%D The consequence is, that the results give a good idea only of the moon phase
+%D but this is most probably precise enough for the purpose of the diary.
+%D The return value of the moon phase calculation can be either a number,
+%D representing the day number in the lunar month, or a command to put a
+%D \METAFUN -graphic (New moon, growing moon, full moon, waning moon).
+%D These little graphics are stored in the file \type{moons-MP.tex}.
+
+\input moons-MP
+
+%D In this file 4 overlays are defined which are used in a dedicated
+%D \type{\framed[]{}} to typeset the pictograms.
+%D
+%M \input ./Moonphase/moons-MP
+%M \defineoverlay[waningmoon][\useMPgraphic{Moon::Waning_moon}]
+%M \defineoverlay[growingmoon][\useMPgraphic{Moon::Growing_moon}]
+%M \defineoverlay[newmoon][\useMPgraphic{Moon::Newmoon}]
+%M \defineoverlay[fullmoon][\useMPgraphic{Moon::Fullmoon}]
+%M \defineframed
+%M [Moon]
+%M [height=1.5\bodyfontsize,
+%M width=1.5\bodyfontsize,
+%M frame=off]
+%D
+%D \starttabulate[|l|r|l|]
+%D \NC \bf Moon phase
+%D \NC \bf Lunar day
+%D \NC \bf Macro
+%D \NC \bf Pictogram \NC\NR
+%D \NC New moon
+%D \NC 0
+%D \NC \type{\Moon[background=newmoon]{}}
+%D \NC \Moon[background=newmoon]{} \NC\NR
+%D \NC Growing moon
+%D \NC 7
+%D \NC \type{\Moon[background=growingmoon]{}}
+%D \NC \Moon[background=growingmoon]{} \NC\NR
+%D \NC Full moon
+%D \NC 15
+%D \NC \type{\Moon[background=fullmoon]{}}
+%D \NC \Moon[background=fullmoon]{} \NC\NR
+%D \NC Waning moon
+%D \NC 22
+%D \NC \type{\Moon[background=waningmoon]{}}
+%D \NC \Moon[background=waningmoon]{} \NC\NR
+%D \stoptabulate
+%D \stopsubject
+
+%D \startsubject[title=Sun pictograms]
+%D
+%D The calculations for the sun rise and sun set times is based on work of
+%D Alexander Yakushev. The results of his calculations nicely correspond with
+%D results obtained from the Open Weather Map website.
+%D
+%D For sunrise, sunset and light hours exist three \METAFUN\ drawings.
+%D These are included in the directory \type{Solar} in the file
+%D \type{sun-MP.tex}.
+
+\input sun-MP
+
+%D In this file 3 overlays are defined which can then be used as a
+%D background in a dedicated framed environment.
+%M \input ./solar/sun-MP
+%M \defineoverlay[Sunrise][\useMPgraphic{Sun::Sunrise}]
+%M \defineoverlay[Sunset][\useMPgraphic{Sun::Sunset}]
+%M \defineoverlay[Light][\useMPgraphic{Sun::Light}]
+%M \defineframed
+%M [SunA]
+%M [strut=yes,
+%M height=\lineheight,
+%M width=\emwidth,
+%M frame=off,
+%M offset=0pt]
+%M
+%M \defineframed
+%M [SunB]
+%M [strut=yes,
+%M height=\lineheight,
+%M width=\emwidth,
+%M frame=off,
+%M offset=0pt,
+%M location=depth]
+%D
+%D \starttabulate[|l|l|l|]
+%D \NC \bf Sun
+%D \NC \bf Macro
+%D \NC \bf Pictogram \NC\NR
+%D \NC Sunrise
+%D \NC \type{\SunA[background=Sunrise,height=8pt]{\strut}}
+%D \NC \SunA[background=Sunrise,height=8pt]{\strut} \NC\NR
+%D \NC Sunset
+%D \NC \type{\SunA[background=Sunset,height=8pt]{\strut}}
+%D \NC \SunA[background=Sunset,height=8pt]{\strut} \NC\NR
+%D \NC Light hours
+%D \NC \type{\SunB[background=Light,height=8pt]{\strut}}
+%D \NC \SunB[background=Light,height=8pt]{\strut} \NC\NR
+%D \stoptabulate
+%D \stopsubject
+
+%D \startsubject[title={The variable sets}]
+%D
+%D The module uses six sets of variables. The first set contains
+%D the information on the
+%D calendars to be calculated.
+
+%D First of all it has to be stated, that the whole idea behind
+%D this module is to prepare a personal organizer with as few
+%D parameters as possible. After the initial setup of the variables
+%D it is sufficient to adapt the values in the first set and once
+%D every year the information on the dates of the Day Light Saving
+%D Time in the last set must be adjusted.
+%D
+%D \startsubsubject[title={Variable set \bf PocketDiary}]
+%D
+%D \starttabulate[|l|l|p|]
+%D \NC \bf Variable \NC \bf Value \NC \bf Comment \NC\NR
+%D \NC WeekDay \NC number \NC Values between 1 and 7. \NC\NR
+%D \NC Week \NC number \NC Values between 1 and 53 \NC\NR
+%D \NC Month \NC number \NC Values between 1 and 12 \NC\NR
+%D \NC Year \NC number \NC Year numbers in the range 1900 and 4099.
+%D The lower limit is computer dependent (OS-timestamp), the upper limit
+%D is depending on the Easter Sunday calculation.\crlf
+%D (http://www.assa.org.au/edm.html, R.W. Mallen, 1985).\NC\NR
+%D \NC Nextyear \NC yes/no \NC The testing is done on \quote{yes}. If set
+%D to \quote{yes} the next year instead of the current year is used for
+%D the calculation of the year calendar. \NC\NR
+%D \NC Daybyday \NC yes/no \NC The testing is done on \quote{yes}. If this
+%D variable is set to \quote{yes} then a diary is typeset with 1 page per
+%D day and the weekend is typeset with Saturday and Sunday on one page.
+%D This uses 6 pages and we can freely choose what should be typeset on
+%D the pages 7 and 8. \NC\NR
+%D \stoptabulate
+%D \stopsubsubject
+
+\setvariables
+ [PocketDiary]
+ [WeekDay=1,
+ Week=17,
+ Month=5,
+ Year=2011,
+ Nextyear=no,
+ Daybyday=no]
+
+%D \startsubsubject[title={Variable set \bf PocketDiaryLayout}]
+%D
+%D The PocketDiary can be given a layout according to your own ideas.
+%D There are 8 variables (Page1 up to Page
+%D 8) which can be given different values.
+%D
+%D \starttabulate[|l|p|]
+%D \NC \bf Variable \NC \bf Comment \NC\NR
+%D \NC Dayplan \NC The weekday indicated in the variable \quote{WeekDay}
+%D in the previous section is used to make a PocketDiary page. \NC\NR
+%D \NC Weekendplan \NC The weekend of the chosen week (variable \quote{Week})
+%D is typeset on a single page \NC\NR
+%D \NC Weekcurrentplan \NC A week calendar based on the variable
+%D \quote{Week}
+%D in the previous section is used for the presentation of a week table.
+%D \NC\NR
+%D \NC Weeknextplan \NC A week calendar based on the variable \quote{Week}
+%D $+$ 1 in the previous section is used for the presentation of the nexts
+%D week's table. \NC\NR
+%D \NC Monthcurrentplan \NC A month table based on the value in the variable
+%D \quote{Month} in the previous section is typeset. \NC\NR
+%D \NC Monthnextplan \NC A month table of the next month based on the
+%D value
+%D in the variable \quote{Month} of the previous section is typeset.
+%D \NC\NR
+%D \NC Yearcurrentplan \NC A complete year calendar of the year given in the
+%D variable \quote{Year} in the previous section is typeset. \NC\NR
+%D \NC Yearnextplan \NC If the \quote{Nextyear}
+%D variable in the previous section is \quote{yes}, then a complete year
+%D calendar for the next year indicated in the
+%D variable \quote{Year} of the previous section is typeset. \NC\NR
+%D \NC Lost-Returnto \NC A page with the indicated information in the
+%D PocketDiaryAddress variable set is used to compose and typeset
+%D a lost and return page (see next section). \NC\NR
+%D \NC Blank \NC This page carries a header and a footer but is
+%D empty for the rest. \NC\NR
+%D \NC Todo \NC A todo-list template is typeset. \NC\NR
+%D \NC Caro \NC A page with full-grid-paper is typeset. \NC\NR
+%D \NC Lines \NC A page with grid lines is typeset. \NC\NR
+%D \NC Contact \NC A form with two sets of preprinted fields
+%D for marking down contact information is typeset. \NC\NR
+%D \stoptabulate
+%D
+%D A basic setup could look as follows:
+
+\setvariables
+ [PocketDiaryLayout]
+ [Page1=Lost-Returnto,
+ Page2=Weekplan,
+ Page3=Dayplan,
+ Page4=Monthcurrentplan,
+ Page5=Blank,
+ Page6=Lines,
+ Page7=Caro,
+ Page8=Contact]
+
+%D \stopsubsubject
+%D
+%D \startsubsubject[title={Variable set \bf PocketDiaryAddress}]
+%D
+%D The third section of variables contains information used for the footer
+%D and the lost-return form.
+%D \stopsubsubject
+
+\setvariables
+ [PocketDiaryAddress]
+ [Familyname=Egger,
+ Forename=Willi,
+ Street={Townstreet 3B},
+ Zipcode=5000,
+ City={New Beach},
+ Country=TEX-world,
+ Phone={+22 444 55 88 66},
+ Mobile={+22 6 19 19 1717},
+ E-mail={info at pocketdiary.org},
+ Web=www.pocketdiary.org]
+
+%D \startsubsubject[title={Variable set \bf PocketDiaryColors}]
+%D
+%D The PocketDiary uses some color. The header and footer separator lines can
+%D be given a color. Standard color is blue.
+%D
+%D For those who want gridlines other than light gray can set a
+%D color for the gridlines too.
+%D \stopsubsubject
+
+\setvariables
+ [PocketDiaryColors]
+ [Separatorline=blue,
+ Gridline={s=.55}]
+
+%D \startsubsubject[title={Variable set \bf PocketDiaryFooter}]
+%D
+%D The footer is filled with three fields. These fields may contain the contents
+%D of variables or \TEX\ commands. The setup of the footer is done with a buffer
+%D in order to be able to call it later on.
+%D \stopsubsubject
+%D \stopsubject
+%D
+%D \startsubject[title={Footer setup}]
+%D \stopsubject
+
+\setvariables
+ [PocketDiaryFooter]
+ [Lefttext=PocketDiary,
+ Centertext=\pagenumber,
+ Righttext={\getvariable{PocketDiaryAddress}{Forename},~\currentdate[year]}] %{\currentdate[year]}
+
+\startbuffer[Footertext]
+ \setupfootertexts[%
+ \tfx
+ \getvariable{PocketDiaryFooter}{Lefttext}
+ \hfill
+ \getvariable{PocketDiaryFooter}{Centertext}
+ \hfill
+ \getvariable{PocketDiaryFooter}{Righttext}]
+\stopbuffer
+
+\getbuffer[Footertext]
+
+%D \startsubject[title={Variable set \bf PocketDiaryGeoPosition}]
+%D
+%D For the sun data calculations you need to know the latitude and longitude of
+%D your location.
+%D
+%D For correct calculations you need also to pass the timezone offset to Lua.
+%D
+%D The dates for the begin and end of the day light saving time (DST)
+%D are calculated based on the continent information. Possible values are
+%D \quote{EU} and \quote{US}. If the field is empty, then no DST is calculated.
+%D
+%D For the US (except for Arizona and Hawaii) currently the DST starts on the
+%D second Sunday of March and ends on the first Sunday of November.
+%D
+%D for Europe currently the DST starts on the last Sunday of March and ends on
+%D the last Sunday of October.
+%D
+%D Sun data are typeset on the \quote{Dayplan} and \quote{Weekendplan} as well
+%D as on Tuesdays in the week-calendar.
+%D \stopsubject
+
+\setvariables %Koziegłowy
+ [PocketDiaryGeoPosition]
+ [lat=52.467860,
+ lon=16.981240,
+ timeoffset=1,
+ continent=EU]
+
+%D \startsubject[title={The various calendar pages}]
+%D
+%D Most of the activities for creating the contents and layout of the
+%D different pages like day, weekend, week, month and year calendars
+%D is delegated to Lua. Those pages are made-up as
+%D \CONTEXT -Lua-documents (cld).
+%D We preload the Lua -file with
+
+\ctxloadluafile{t-pocketdiary}{}
+
+%D \startsubsubject[title={Day plan}]
+%D
+%D \startplacefigure
+%D [location={middle,here},
+%D reference=fig:Singleday,
+%D title={Example Day-calendar}]
+%D {\externalfigure[docu-figures][page=1,width=.4\textwidth,frame=on]}
+%D \stopplacefigure
+%D
+%D The day calendar looks as in \in{figure}[fig:Singleday].
+%D
+%D Next to the day number of the selected month the day name is given. If the
+%D day is a christian feast day, its name is following after the day name.
+%D To the right the week number and the year is typeset.
+%D
+%D The configuration of the page looks as follows:
+
+\startsetups table:topinfo
+ \setupTABLE[each][each][frame=off]
+ \setupTABLE[r][1][offset=0pt,loffset=1pt,roffset=1pt,align=lohi] % Date row
+ \setupTABLE[r][2][height=1.3\bodyfontsize,frame=off,offset=0pt] % Astronomy row
+ \setupTABLE[c][1][style=bold,width=0.25\textwidth] % Day
+ \setupTABLE[c][2][width=0.35\textwidth,align=lohi] % Feastname column
+ \setupTABLE[c][3][width=0.4\textwidth,
+ align={flushright,lohi}] % Month / year column
+\stopsetups
+
+\startsetups table:topweekplan
+ \setupTABLE[each][each][frame=off]
+ \setupTABLE[r][1][offset=0pt,loffset=3pt,roffset=3pt,align=lohi] % Date row
+ \setupTABLE[c][1][style=bold,width=0.5\textwidth,align=lohi] % Name
+ \setupTABLE[c][2][style={\switchtobodyfont[6pt]},width=0.5\textwidth,
+ align={flushright,lohi}] % Week, year
+\stopsetups
+
+%D For the creation of the page a command with 8 parameters is defined:
+
+\define[8]\Dayplan{\ctxlua{thirddata.diary.dayplan(#1,#2,#3,#4,#5,#6,#7,#8)}}
+
+%D The Dayplan-command with the collected parameters is placed in a buffer. This buffer is later called from the user-file \type{PocketDiary.tex} .
+
+\startbuffer[Dayplan]
+ \Dayplan %Weekday,Week,Month,Year,lat,lon,timeoffset,continent
+ {\getvariable{PocketDiary}{WeekDay}}
+ {\getvariable{PocketDiary}{Week}}
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+ {\getvariable{PocketDiaryGeoPosition}{lat}}
+ {\getvariable{PocketDiaryGeoPosition}{lon}}
+ {\getvariable{PocketDiaryGeoPosition}{timeoffset}}
+ {"\getvariable{PocketDiaryGeoPosition}{continent}"}
+\stopbuffer
+
+%D \stopsubsubject
+
+%D \startsubsubject[title={Weekend}]
+%D
+%D The weekend calendar shows Saturday and Sunday on one page
+%D (see \in{figure}[fig:Weekend]).
+%D
+%D The typeset data are identical to those of the \quote{Dayplan}
+%D
+%D \startplacefigure
+%D [location={middle,here},
+%D reference=fig:Weekend,
+%D title={Example Weekend-calendar}]
+%D {\externalfigure[docu-figures][page=2,width=.4\textwidth,frame=on]}
+%D \stopplacefigure
+
+%D Comparable to the Dayplan the Weekendplan command is defined with 8 parameters.
+
+\define[8]\Weekendplan{\ctxlua{thirddata.diary.weekendplan(#1,#2,#3,#4,#5,#6,#7,#8)}}
+
+%D Again this command with the collected information of the 8 parameters is placed in a buffer which is called then from the user-file \type{PocketDiary.tex} .
+
+\startbuffer[Weekendplan]
+ \Weekendplan %Weekday,Week,Month,Year,lat,lon,timeoffset,continent
+ {6}
+ {\getvariable{PocketDiary}{Week}}
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+ {\getvariable{PocketDiaryGeoPosition}{lat}}
+ {\getvariable{PocketDiaryGeoPosition}{lon}}
+ {\getvariable{PocketDiaryGeoPosition}{timeoffset}}
+ {"\getvariable{PocketDiaryGeoPosition}{continent}"}
+\stopbuffer
+
+%D \stopsubsubject
+
+%D \startsubsubject[title={Week plan and next week plan}]
+%D
+%D The week calendar is a one-column table for working days.
+%D Saturday and Sunday are placed next to each other in the last table row. An
+%D example is given
+%D in \in{figure}[fig:Week].
+%D
+%D In the \quote{Weekplan} header appears \quote{Weeek agenda} or its
+%D correspondent name in the supported languages. To the right the month's
+%D number, weeknumber and year are typeset.
+
+%D \startplacefigure
+%D [location={middle,here},
+%D reference=fig:Week,
+%D title={Example Week-calendar}]
+%D {\externalfigure[docu-figures][page=3,width=.4\textwidth,frame=on]}
+%D \stopplacefigure
+%D By means of a setups-sequence the table is defined as follows:
+
+\startsetups table:week
+ \setupTABLE[r][each][height=.158\textheight,align=flushleft] %.165
+ \setupTABLE[r][even][background=color,backgroundcolor=.5s]
+ \setupTABLE[c][1][width=.5\textwidth]
+ \setupTABLE[c][2][width=.5\textwidth]
+\stopsetups
+
+%D Again the Weekcurrentplan-command is defined with 8 parameters
+
+\define[8]\Weekcurrentplan{\ctxlua{thirddata.diary.weekplan(#1,#2,#3,#4,#5,#6,#7,#8)}}
+
+%D And the command together with the gathered parameters is stored in a buffer, which will be used by the user-file \type{PocketDiary.tex} .
+
+\startbuffer[Weekcurrentplan]
+ \Weekcurrentplan %Weekday,Week,Month,Year,lat,lon,timeoffset,continent
+ {1}
+ {\getvariable{PocketDiary}{Week}}
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+ {\getvariable{PocketDiaryGeoPosition}{lat}}
+ {\getvariable{PocketDiaryGeoPosition}{lon}}
+ {\getvariable{PocketDiaryGeoPosition}{timeoffset}}
+ {"\getvariable{PocketDiaryGeoPosition}{continent}"}
+ \page[yes]
+\stopbuffer
+
+%D Similar to the week plan the next week plan is built.
+
+\define[8]\Weeknextplan{\ctxlua{thirddata.diary.weekplan(#1,#2,#3,#4,#5,#6,#7,#8)}}
+
+\startbuffer[Weeknextplan]
+ \Weeknextplan %Weekday,Week,Month,Year,lat,lon,timeoffset,dst_start,dst_stop
+ {1}
+ {\directlua{tex.print{\getvariable{PocketDiary}{Week}+1}}}
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+ {\getvariable{PocketDiaryGeoPosition}{lat}}
+ {\getvariable{PocketDiaryGeoPosition}{lon}}
+ {\getvariable{PocketDiaryGeoPosition}{timeoffset}}
+ {"\getvariable{PocketDiaryGeoPosition}{continent}"}
+ \page[yes]
+\stopbuffer
+
+%D \stopsubsubject
+
+%D \startsubsubject[title={Month current and month next}]
+%D
+%D The month calendar looks as in \in{figure}[fig:Month].
+%D
+%D Left in the header appears the month name in the chosen language. To the
+%D right the year is typeset.
+%D
+%D \startplacefigure
+%D [location={middle,here},
+%D reference=fig:Month,
+%D title={Example Month-calendar}]
+%D {\externalfigure[docu-figures][page=4,width=.4\textwidth,frame=on]}
+%D \stopplacefigure
+%D In the same fashion as the previous items also the month and
+%D next month calendars are defined respectively setup:
+
+\startsetups table:month
+ \setupTABLE[column][each][width=.143\textwidth,align=flushright,offset=3pt]
+ \setupTABLE[column][7][style=\red]
+\stopsetups
+
+%D For the Month-calendars we need only two parameters: month and year.
+
+\define[2]\Monthcurrentplan{\ctxlua{thirddata.diary.monthcurrentplan(#1,#2)}}
+
+%D The command is kept together with the gathered parameters in a buffer again.
+%D This will be called from the user-file \type{PocketDiary.tex} .
+
+\startbuffer[Monthcurrentplan]
+ \Monthcurrentplan
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+\stopbuffer
+
+\define[2]\Monthnextplan{\ctxlua{thirddata.diary.monthnextplan(#1,#2)}}
+
+\startbuffer[Monthnextplan]
+ \Monthnextplan
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+\stopbuffer
+
+%D \stopsubsubject
+
+
+%D \startsubsubject[title={Year current and year next}]
+%D
+%D The year calendar looks as in \in{figure}[fig:Year].
+%D
+%D In the header the year only is typeset.
+%D
+%D \startplacefigure
+%D [location=middle,
+%D reference=fig:Year,
+%D title={Example Year-calendar}]
+%D {\externalfigure[docu-figures][page=5,width=.4\textwidth,frame=on]}
+%D \stopplacefigure
+%D The year table(s) are prepared as the week tables with a table-setup
+%D sequence, a custom command which resides with the parameters assigned in a
+%D buffer, which will again be called from the user-file \type{PocketDiary.tex}
+
+\startsetups table:year
+ \setupTABLE[column]
+ [each]
+ [width=.032\textwidth,align=flushright,offset=1pt,frame=off]
+ \setupTABLE[column][1][width=.052\textwidth,align=flushleft]
+ \setupTABLE[row][each][offset=1pt,height=1.5\bodyfontsize]
+\stopsetups
+
+\define[2]\Yearcurrentplan{\ctxlua{thirddata.diary.yearplan(#1,#2)}}
+\define[2]\Yearnextplan{\ctxlua{thirddata.diary.yearplan(#1,#2)}}
+
+\startbuffer[Yearcurrentplan]
+ \Yearcurrentplan
+ {\getvariable{PocketDiary}{Year}}
+ {"no"}
+\stopbuffer
+
+\startbuffer[Yearnextplan]
+ \Yearnextplan
+ {\getvariable{PocketDiary}{Year}}
+ {"\getvariable{PocketDiary}{Nextyear}"}
+\stopbuffer
+
+%D \stopsubsubject
+
+%D \startsubsubject[title= {One week\dots}]
+%D
+%D As mentioned before, the result will be 5 pages with one working day per
+%D page and the weekend on one page i.e. 6 pages. For the pages 7 and 8 the
+%D values defined in the \quote{PocketDiaryLayout} variable set is used.
+%D As for the Dayplan we need a command carrying 8 parameters:
+
+\define[8]\Daybyday{\ctxlua{thirddata.diary.daybydayplan(#1,#2,#3,#4,#5,#6,#7,#8)}}
+
+%D A buffer contains the command just defined with the gathered information for the parameters. The buffer then is called from the user-file \type{PocketDiary.tex} .
+
+\startbuffer[Daybyday]
+ \Daybyday
+ {1} %Weekday
+ {\getvariable{PocketDiary}{Week}}
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+ {\getvariable{PocketDiaryGeoPosition}{lat}}
+ {\getvariable{PocketDiaryGeoPosition}{lon}}
+ {\getvariable{PocketDiaryGeoPosition}{timeoffset}}
+ {"\getvariable{PocketDiaryGeoPosition}{continent}"}
+\stopbuffer
+
+%D \stopsubsubject
+
+%D \startsubsubject[title={Templates}]
+%D
+%D The PocketDiary comes with a couple of templates for writing down
+%D information:
+
+%D For the pages with (grid)lines we use an overlay in the background of
+%D the text area which will contain the \METAPOST -graphic.
+%D
+%D \startplacefigure
+%D [location={middle,here},
+%D title={The set of available templates}]
+%D {\startcombination[3*2]
+%D {\externalfigure
+%D [docu-figures]
+%D [page=6,width=.25\textwidth,frame=on]}{The blank page}
+%D {\externalfigure
+%D [docu-figures]
+%D [page=7,width=.25\textwidth,frame=on]}{Caro paper}
+%D {\externalfigure
+%D [docu-figures]
+%D [page=8,width=.25\textwidth,frame=on]}{Lines}
+%D {\externalfigure
+%D [docu-figures]
+%D [page=9,width=.25\textwidth,frame=on]}{Todo}
+%D {\externalfigure
+%D [docu-figures]
+%D [page=10,width=.25\textwidth,frame=on]}{Contact information}
+%D {\externalfigure
+%D [docu-figures]
+%D [page=11,width=.25\textwidth,frame=on]}{Lost-return-to information}
+%D \stopcombination}
+%D \stopplacefigure
+%D \stopsubsubject
+%D The setups for the Contacts page look as follows:
+
+\startsetups table:contacts
+ \setupTABLE[r][each][frame=off,bottomframe=on,height=2\lineheight]
+ \setupTABLE[c][1][width=.3\textwidth]
+ \setupTABLE[c][2][width=.5\textwidth]
+ \setupTABLE[c][3][width=.2\textwidth]
+\stopsetups
+
+%D The setups for the Lost-Returnto page is setup in the following way:
+
+\startsetups table:returnto
+ \setupTABLE[r][each][frame=off]
+ \setupTABLE[c][each][width=\textwidth]
+\stopsetups
+
+%D Another setups covers the reset of the used Background
+
+\startsetups Background:stop
+ \defineoverlay
+ [Textarea]
+ [\resetMPdrawing]
+ \setupbackgrounds[text][text][background=]
+\stopsetups
+
+%D All templates for these pages are contained in buffers in order to call them from the user-file \type{PocketDiary.tex}
+
+\startbuffer[Contact]
+ \setupheadertexts[{\bf \labeltext{contact}\hfill}]
+ \switchtobodyfont[6pt]
+ \dorecurse{2}{\bTABLE[setups=table:contacts]
+ \bTR
+ \bTD \labeltext{name}: \eTD
+ \bTD \eTD
+ \bTD \eTD
+ \eTR
+ \bTR
+ \bTD \labeltext{address}:\eTD
+ \bTD \eTD
+ \bTD \eTD
+ \eTR
+ \bTR
+ \bTD \strut\eTD
+ \bTD \eTD
+ \bTD \eTD
+ \eTR
+ \bTR
+ \bTD \labeltext{zip}:\eTD
+ \bTD \labeltext{place}:\eTD
+ \bTD \labeltext{country}:\eTD
+ \eTR
+ \bTR
+ \bTD \labeltext{phone}:\eTD
+ \bTD \eTD
+ \bTD \eTD
+ \eTR
+ \bTR
+ \bTD \labeltext{mail}:\eTD
+ \bTD \eTD
+ \bTD \eTD
+ \eTR
+ \eTABLE
+ \blank}
+ \page[yes]
+\stopbuffer
+
+\startbuffer[Caro]
+ \setupheadertexts[{\bf \labeltext{notes}\hfill}]
+ \defineoverlay
+ [Textarea]
+ [\useMPgraphic{Caro}]
+ \setupbackgrounds[text][background=Textarea]
+ \strut
+ \page[yes]
+ \setups{Background:stop}
+\stopbuffer
+
+\startbuffer[Lines]
+ \setupheadertexts[{\bf \labeltext{notes}\hfill}]
+ \defineoverlay
+ [Textarea]
+ [\useMPgraphic{Lines}]
+ \setupbackgrounds[text][text][background=Textarea]
+ \strut
+ \page[yes]
+ \setups{Background:stop}
+\stopbuffer
+
+\startbuffer[Todo]
+ \defineoverlay
+ [Textarea]
+ [\useMPgraphic{Todo}]
+ \setupbackgrounds[text][text][background=Textarea]
+ \setupheadertexts[\bf \labeltext{todo}\hfill]
+ \strut
+ \page[yes]
+ \setups{Background:stop}
+\stopbuffer
+
+\startbuffer[Blank]
+ \setupheadertexts[{\bf \labeltext{notes}\hfill}]
+ \strut
+ \page[yes]
+\stopbuffer
+
+\startbuffer[Lost-Returnto]
+ \strut
+ \setupheadertexts[{\bf \labeltext{calendar}}]
+ \setupfooter[state=empty]
+ \setupbackgrounds[footer][text][topframe=off]
+ \setups{Background:stop}
+ \strut
+ \blank[2*line]
+ \framed[width=\textwidth,
+ frame=off,
+ bottomframe=on,
+ align=flushleft,
+ rulethickness=1pt,
+ foregroundcolor=\getvariable{PocketDiaryColors}{Separatorline},
+ framecolor=\getvariable{PocketDiaryColors}{Separatorline}]
+ {\labeltext{found}}
+ \bTABLE[setups=table:returnto]
+ \bTR
+ \bTD \getvariable{PocketDiaryAddress}{Forename}~
+ \getvariable{PocketDiaryAddress}{Familyname} \eTD
+ \eTR
+ \bTR
+ \bTD \getvariable{PocketDiaryAddress}{Street} \eTD
+ \eTR
+ \bTR
+ \bTD \getvariable{PocketDiaryAddress}{Zipcode}
+ {\addff{f:smallcaps}\getvariable{PocketDiaryAddress}{City}}\eTD
+ \eTR
+ \bTR
+ \bTD Tel: \getvariable{PocketDiaryAddress}{Phone}\eTD
+ \eTR
+ \bTR
+ \bTD Mob: \getvariable{PocketDiaryAddress}{Mobile}\eTD
+ \eTR
+ \bTR
+ \bTD E-mail: \getvariable{PocketDiaryAddress}{E-mail} \eTD
+ \eTR
+ \bTR
+ \bTD Web: \getvariable{PocketDiaryAddress}{Web} \eTD
+ \eTR
+ \eTABLE
+ \page[yes]
+ \getbuffer[Footertext]
+ \setupbackgrounds[footer][text][topframe=on]
+\stopbuffer
+
+%D \stopsubject
+%D
+%D \startsubject[title={The setup of the PocketDiary}]
+%D
+%D When filling the 8 pages we can do two things. Either we let \CONTEXT\
+%D typeset the pages as we choose them in the section \quote{PocketDiaryLayout}
+%D or we set the variable \quote{Daybyday} in the variable set
+%D \quote{PocketDiary} to \quote{yes}. This leads to the typesetting of 5 pages
+%D with each a working day and the weekend on one page. The remaining two pages
+%D are typeset according to the values given in \quote{PocketDiaryLayout.}
+
+\startbuffer[Pocketdiary]
+ \definecolor[Grid][\getvariable{PocketDiaryColors}{Gridline}]
+ \definecolor[Separatorline][\getvariable{PocketDiaryColors}{Separatorline}]
+
+ \doifelse{\getvariable{PocketDiary}{Daybyday}}{yes}
+ {\Daybyday %creates 6 pages
+ {1}
+ {\getvariable{PocketDiary}{Week}}
+ {\getvariable{PocketDiary}{Month}}
+ {\getvariable{PocketDiary}{Year}}
+ {\getvariable{PocketDiaryGeoPosition}{lat}}
+ {\getvariable{PocketDiaryGeoPosition}{lon}}
+ {\getvariable{PocketDiaryGeoPosition}{timeoffset}}
+ {"\getvariable{PocketDiaryGeoPosition}{continent}"}
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page7}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page8}]
+ }
+ {\getbuffer[\getvariable{PocketDiaryLayout}{Page1}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page2}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page3}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page4}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page5}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page6}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page7}]
+ \getbuffer[\getvariable{PocketDiaryLayout}{Page8}]
+ }
+\stopbuffer
+
+%D \stopsubject
+
+%D \startsubject[title={Arranging the pages}]
+%D
+%D For the arrangement of the 8 pages on the paper we need a
+%D special arranging scheme, which is included in the distribution.
+%D Invoking the scheme is performed with
+%D
+%D \type{\setuparranging[1*8]}
+%D
+%D The arrangement of the 8 pages is not switched on in this file. For the
+%D purpose of experimenting it is better to keep this command in the user file
+%D \type{\type{PocketDiary.tex} }
+%D
+%D \stopsubject
+
+%D \startsubject[title={How to fold the PocketDiary}]
+%D
+%D The eight printed pages are folded in such a way, that the PocketDiary
+%D presents itself as a small booklet.
+%D There are no empty pages visible.
+%D
+%D \startplacefigure
+%D [location=middle,
+%D reference=fig:schemeA,
+%D title={The basic folding scheme}]
+%D {\externalfigure[docu-figures][page=12,width=.6\textwidth]}
+%D \stopplacefigure
+%D
+%D First make two mountain-folds as indicated with the straight lines in
+%D \in{figure}[fig:schemeA].
+%D Unfold the paper and turn it face up and \unit{90 Degrees} to the left.
+%D Make a valley-fold with the lower part
+%D of the sheet on the previously made mountain-fold. Unfold and turn the
+%D sheet \unit{180 Degrees}.
+%D Make another valley-fold as described before. Unfold the sheet.
+%D
+%D Take a sharp knife and a ruler. Slit the paper open between Cuttingpoint A
+%D and B (see \in{figure}[fig:schemeA]).
+%D
+%D Now we can fold the booklet. First fold the paper again in the length. Then
+%D hold the double folded paper
+%D with the mountain-fold up. Push from both sides towards the center in order
+%D to get a form similar
+%D to \in{figure}[fig:schemeB]. Fold then the upper double-page in direction B,
+%D the lower double-page
+%D in direction C and finally the lefthand double-sided page in direction D.
+%D
+%D \startplacefigure
+%D [location=middle,
+%D reference=fig:schemeB,
+%D title={The basic folding scheme}]
+%D {\externalfigure[docu-figures][page=13,width=.6\textwidth]}
+%D \stopplacefigure
+%D
+%D Before creasing the booklet at the spine it is worthwhile to put the section
+%D on table and adjust
+%D folds where needed. Finally the spine is creased with preference with a
+%D bone-folder.
+%D \stopsubject
+
+\stopmodule
\ No newline at end of file
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2023-04-26 19:41:30 UTC (rev 66948)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2023-04-26 19:43:18 UTC (rev 66949)
@@ -215,7 +215,7 @@
context-french context-fullpage
context-gantt context-gnuplot context-handlecsv
context-layout context-letter context-lettrine context-mathsets
- context-notes-zh-cn context-rst context-ruby
+ context-notes-zh-cn context-pocketdiary context-rst context-ruby
context-simplefonts context-simpleslides context-title
context-transliterator context-typearea context-typescripts context-vim
context-visualcounter
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds 2023-04-26 19:41:30 UTC (rev 66948)
+++ trunk/Master/tlpkg/libexec/ctan2tds 2023-04-26 19:43:18 UTC (rev 66949)
@@ -365,7 +365,7 @@
'context-lettrine', "&MAKEcopy",
'context-lilypond', "die 'skipping, obsolete per author'",
'context-mathsets', "&MAKEcopy",
- 'context-pocketdiary', "die 'skipping, generic filenames'",
+ 'context-pocketdiary', "&MAKEcopy",
'context-rst', "&MAKEcopy",
'context-ruby', "&MAKEcopy",
'context-sgf', "die 'skipping, obsolete per author'",
Modified: trunk/Master/tlpkg/tlpsrc/collection-context.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-context.tlpsrc 2023-04-26 19:41:30 UTC (rev 66948)
+++ trunk/Master/tlpkg/tlpsrc/collection-context.tlpsrc 2023-04-26 19:43:18 UTC (rev 66949)
@@ -34,6 +34,7 @@
depend context-lettrine
depend context-mathsets
depend context-notes-zh-cn
+depend context-pocketdiary
depend context-rst
depend context-ruby
depend context-simplefonts
Added: trunk/Master/tlpkg/tlpsrc/context-pocketdiary.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/context-pocketdiary.tlpsrc (rev 0)
+++ trunk/Master/tlpkg/tlpsrc/context-pocketdiary.tlpsrc 2023-04-26 19:43:18 UTC (rev 66949)
@@ -0,0 +1,2 @@
+category ConTeXt
+depend context
More information about the tex-live-commits
mailing list.