POV-Ray : Newsgroups : povray.binaries.images : Calendar Macro [10.8kb] Server Time
18 Oct 2026 05:45:01 EDT (-0400)
  Calendar Macro [10.8kb] (Message 1 to 26 of 26)  
From: Tom Melly
Subject: Calendar Macro [10.8kb]
Date: 21 Nov 2001 12:27:27
Message: <3bfbe3ff@news.povray.org>
Mucking about with date algorithms.

The following macros will generate a calendar as a string object union for a
specified month/year (yucky example attached):

#macro MakeTOU(MyStr, YTrans) // modify this according to taste
  text {
    ttf             // font type (only TrueType format for now)
    "crystal.ttf",  // Microsoft Windows-format TrueType font file name
    MyStr,      // the string to create
    1,              // the extrusion depth
    0               // inter-character spacing
    translate y*YTrans
  }
#end

#macro MakeCal(Year, Month) // main date algo. macro
  #local YTrans = 0;
  #local YChange = 1.5;
  #local TempStr = "";
  #local Months = array[12]{
    "January","Febuary","March","April",
    "May","June","July","August",
    "September","October","November","December"
  };
  #local Days = array[7]{"Su","Mo","Tu","We","Th","Fr","Sa"};
  #local Day = 1;
  #local RealYear = Year;
  #if (Month < 3)
    #local Month = Month + 12;
    #local Year=Year-1;
  #end
  #local JulDay = Day + int((153 * Month - 457) / 5) + 365 * Year + floor(Year /
4) -
    floor(Year / 100) + floor(Year / 400) + 1721118.5;
  MakeTOU(concat(Months[Month-1], " ",str(RealYear,0,0)), YTrans)

  #local YTrans = YTrans - YChange;

  #local Temp = 0;
  #while(Temp<7)
    #local TempStr=concat(TempStr,Days[Temp], " ")
    #local Temp = Temp+1;
  #end
  MakeTOU(TempStr, YTrans)
  #local TempStr= "";

  #local YTrans = YTrans - YChange;

  #local JulDay = JulDay - 1;
  #local LastDay = -1;
  #local CalDay = 0;
  #local First = 1;
  #while(LastDay < CalDay)
    #local LastDay = CalDay;
    #local JulDay = JulDay + 1;
    #local ModDInt = floor(mod(JulDay + 2, 7));
    #local Z = floor(JulDay - 1721118.5);
    #local R = JulDay - 1721118.5 - Z;
    #local G = Z - 0.25;
    #local A = floor(G / 36524.25);
    #local B = A - floor(A / 4);
    #local CalYear = floor((B+G) / 365.25);
    #local C = B + Z - floor(365.25 * CalYear);
    #local CalMonth = int((5 * C + 456) / 153);
    #local CalDay = C - int((153 * CalMonth - 457) / 5) + R;
    #if (CalMonth > 12)
       #local CalYear = CalYear + 1;
       #local CalMonth = CalMonth - 12;
    #end
    #if(First | CalDay > 1)
      #local First = 0;
      #if(CalDay = 1)
        #local Temp = 0;
        #local TempStr = "";
        #while (Temp < ModDInt)
          #local TempStr = concat(TempStr, "   ")
          #local Temp = Temp + 1;
        #end
      #end
      #local TempStr = concat(TempStr, str(CalDay,2,0)," ")
      #if(ModDInt = 6)
        MakeTOU(TempStr, YTrans)
        #local TempStr = "";
        #local YTrans = YTrans - YChange;
      #end
    #end
  #end
  MakeTOU(TempStr, YTrans)
#end

union{ // example
  MakeCal(2001,6)
  pigment{Red}
  translate x*-7
  translate y*4
}


--
#macro G(D,E,F)#local I=array[3]{D,E,F}#local B=0;triangle{#while(
B<3)#while(I[B])A[mod(I[B],10)]+#local I[B]=div(I[B],10);#end<-5,-
2,9>#local B=B+1;#end}#end #local A=array[7]{x,x*2,x*4,y,y*2,y*4,z
}light_source{-x*6-z*9,1}mesh{G(105,10,146)G(105,246,10)G(105,56,
146)G(105,1256,246)G(1256,126,220)G(22156,2216,201)pigment{rgb 1}}//TM


Post a reply to this message


Attachments:
Download 'c1.jpg' (11 KB)

Preview of image 'c1.jpg'
c1.jpg


 

From: Jan Walzer
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 12:51:37
Message: <3bfbe9a9@news.povray.org>
The week starts with Monday!!!
I don't work at Sundays ... why does everybody do this wrong ?

SCNR ....

--
Jan Walzer <jan### [at] lzernet>


Post a reply to this message

From: ingo
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 12:52:53
Message: <Xns9160C011FF3C1seed7@povray.org>
in news:3bfbe3ff@news.povray.org Tom Melly wrote:

> Mucking about with date algorithms.
> 

Moving :
  MakeTOU(concat(Months[Month-1], " ",str(RealYear,0,0)), YTrans)
to the line above:
  #if (Month < 3)
prevents an error for the months jan and feb.


Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: OT Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 13:41:59
Message: <3bfbf577@news.povray.org>
Jan Walzer schrieb in Nachricht <3bfbe9a9@news.povray.org>...
>The week starts with Monday!!!
>I don't work at Sundays ... why does everybody do this wrong ?


OT: Do you have to earn your free day by the work of the week or do you get
it for free and therefore are able to work the next few days?

Marc-Hendrik


Post a reply to this message

From: Tom Melly
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 14:56:34
Message: <3bfc06f2@news.povray.org>
"ingo" <ing### [at] homenl> wrote in message
news:Xns### [at] povrayorg...
>
> Moving :
>   MakeTOU(concat(Months[Month-1], " ",str(RealYear,0,0)), YTrans)
> to the line above:
>   #if (Month < 3)
> prevents an error for the months jan and feb.
>
>
> Ingo
>

Already dealt with - RealYear is a copy of Year prior to the jan-mar thing -
However, your suggestion save needing RealYear in the first place... Ta.

I've got a bit of enhancement and optomising to do, and will post an update
later.


Post a reply to this message

From: Tom Melly
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 14:57:21
Message: <3bfc0721@news.povray.org>
"Jan Walzer" <jan### [at] lzernet> wrote in message
news:3bfbe9a9@news.povray.org...
> The week starts with Monday!!!
> I don't work at Sundays ... why does everybody do this wrong ?
>

I'll parametise that in the next version (as well as height-offset and
suchlike).


Post a reply to this message

From: Bill DeWitt
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 15:14:30
Message: <3bfc0b26$1@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3bfbe3ff@news.povray.org...
> Mucking about with date algorithms.

    Do you have the getdate.bat system to make povray read the system clock
and generate today's calendar?


Post a reply to this message

From: Tom Melly
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 18:31:05
Message: <3bfc3939$1@news.povray.org>
Okay, posted improved version with more params to b.scene-files...


Post a reply to this message

From: Tom Melly
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 18:32:56
Message: <3bfc39a8$1@news.povray.org>
"Bill DeWitt" <bde### [at] cflrrcom> wrote in message
news:3bfc0b26$1@news.povray.org...
>
>     Do you have the getdate.bat system to make povray read the system
clock
> and generate today's calendar?
>

No, the scene uses pov lang to implement algorithms I found on a website (or
did you mean in general?)


Post a reply to this message

From: blessing
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 21:09:00
Message: <3bfc5e3c@news.povray.org>
intereting idea, now I have to make a nice background for mine.....

G.

Tom Melly <tom### [at] tomandlucouk> wrote in message
news:3bfbe3ff@news.povray.org...
> Mucking about with date algorithms.
>
> The following macros will generate a calendar as a string object union for
a
> specified month/year (yucky example attached):
>
> #macro MakeTOU(MyStr, YTrans) // modify this according to taste
>   text {
>     ttf             // font type (only TrueType format for now)
>     "crystal.ttf",  // Microsoft Windows-format TrueType font file name
>     MyStr,      // the string to create
>     1,              // the extrusion depth
>     0               // inter-character spacing
>     translate y*YTrans
>   }
> #end
>
> #macro MakeCal(Year, Month) // main date algo. macro
>   #local YTrans = 0;
>   #local YChange = 1.5;
>   #local TempStr = "";
>   #local Months = array[12]{
>     "January","Febuary","March","April",
>     "May","June","July","August",
>     "September","October","November","December"
>   };
>   #local Days = array[7]{"Su","Mo","Tu","We","Th","Fr","Sa"};
>   #local Day = 1;
>   #local RealYear = Year;
>   #if (Month < 3)
>     #local Month = Month + 12;
>     #local Year=Year-1;
>   #end
>   #local JulDay = Day + int((153 * Month - 457) / 5) + 365 * Year +
floor(Year /
> 4) -
>     floor(Year / 100) + floor(Year / 400) + 1721118.5;
>   MakeTOU(concat(Months[Month-1], " ",str(RealYear,0,0)), YTrans)
>
>   #local YTrans = YTrans - YChange;
>
>   #local Temp = 0;
>   #while(Temp<7)
>     #local TempStr=concat(TempStr,Days[Temp], " ")
>     #local Temp = Temp+1;
>   #end
>   MakeTOU(TempStr, YTrans)
>   #local TempStr= "";
>
>   #local YTrans = YTrans - YChange;
>
>   #local JulDay = JulDay - 1;
>   #local LastDay = -1;
>   #local CalDay = 0;
>   #local First = 1;
>   #while(LastDay < CalDay)
>     #local LastDay = CalDay;
>     #local JulDay = JulDay + 1;
>     #local ModDInt = floor(mod(JulDay + 2, 7));
>     #local Z = floor(JulDay - 1721118.5);
>     #local R = JulDay - 1721118.5 - Z;
>     #local G = Z - 0.25;
>     #local A = floor(G / 36524.25);
>     #local B = A - floor(A / 4);
>     #local CalYear = floor((B+G) / 365.25);
>     #local C = B + Z - floor(365.25 * CalYear);
>     #local CalMonth = int((5 * C + 456) / 153);
>     #local CalDay = C - int((153 * CalMonth - 457) / 5) + R;
>     #if (CalMonth > 12)
>        #local CalYear = CalYear + 1;
>        #local CalMonth = CalMonth - 12;
>     #end
>     #if(First | CalDay > 1)
>       #local First = 0;
>       #if(CalDay = 1)
>         #local Temp = 0;
>         #local TempStr = "";
>         #while (Temp < ModDInt)
>           #local TempStr = concat(TempStr, "   ")
>           #local Temp = Temp + 1;
>         #end
>       #end
>       #local TempStr = concat(TempStr, str(CalDay,2,0)," ")
>       #if(ModDInt = 6)
>         MakeTOU(TempStr, YTrans)
>         #local TempStr = "";
>         #local YTrans = YTrans - YChange;
>       #end
>     #end
>   #end
>   MakeTOU(TempStr, YTrans)
> #end
>
> union{ // example
>   MakeCal(2001,6)
>   pigment{Red}
>   translate x*-7
>   translate y*4
> }
>
>
> --
> #macro G(D,E,F)#local I=array[3]{D,E,F}#local B=0;triangle{#while(
> B<3)#while(I[B])A[mod(I[B],10)]+#local I[B]=div(I[B],10);#end<-5,-
> 2,9>#local B=B+1;#end}#end #local A=array[7]{x,x*2,x*4,y,y*2,y*4,z
> }light_source{-x*6-z*9,1}mesh{G(105,10,146)G(105,246,10)G(105,56,
> 146)G(105,1256,246)G(1256,126,220)G(22156,2216,201)pigment{rgb 1}}//TM
>
>
>


Post a reply to this message

From: Arthur Flint
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 21:23:18
Message: <Xns9160D98762310mrartchesapeakenet@204.213.191.226>
Jan Walzer scribis news:3bfbe9a9@news.povray.org:

> The week starts with Monday!!!
> I don't work at Sundays ... why does everybody do this wrong ?
> 

hy should your work week decide how the calendar looks? Just why do you
think they are called "Weekends" Sunday is the start and Saturday is the 
finish.

-- 
Gis poste, Arto.


Post a reply to this message

From: Jan Walzer
Subject: Re: Calendar Macro [10.8kb]
Date: 21 Nov 2001 22:49:10
Message: <3bfc75b6@news.povray.org>
"Arthur Flint" <mra### [at] chesapeakenet> wrote
> Jan Walzer scribis news:3bfbe9a9@news.povray.org:
>
> > The week starts with Monday!!!
> > I don't work at Sundays ... why does everybody do this wrong ?
> >
>
> hy should your work week decide how the calendar looks? Just why do you
> think they are called "Weekends" Sunday is the start and Saturday is the
> finish.


No! ... They both are called weekend, because they are at the END of the WEEK
...
Or don't you call sunday a weekend-day ? Is it a weekstart-day for you ?

--
Jan Walzer <jan### [at] lzernet>


Post a reply to this message

From: Bill DeWitt
Subject: Re: Calendar Macro [10.8kb]
Date: 22 Nov 2001 00:24:56
Message: <3bfc8c28$1@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3bfc39a8$1@news.povray.org...
> "Bill DeWitt" <bde### [at] cflrrcom> wrote in message
> news:3bfc0b26$1@news.povray.org...
> >
> >     Do you have the getdate.bat system to make povray read the system
> clock
> > and generate today's calendar?
> >
>
> No, the scene uses pov lang to implement algorithms I found on a website
(or
> did you mean in general?)


    What I mean is do you have that system so that you can add it to your
macro to allow it to read the system clock and maybe highlight today's date
or automatically make the right month unless you tell it otherwise? If not I
can tell you how to do it.


Post a reply to this message

From: Timothy R  Cook
Subject: Re: Calendar Macro [10.8kb]
Date: 22 Nov 2001 00:45:51
Message: <3BFC9095.D1AB185B@scifi-fantasy.com>
Jan Walzer wrote:
> No! ... They both are called weekend, because they
> are at the END of the WEEK ... Or don't you call
> sunday a weekend-day ? Is it a weekstart-day for you ?

Ends, plural.  A line segment (in this case, the work
week) has two ends.  Hence weekend, similar to bookend,
is at either locus.
-- 
Tim Cook
http://empyrean.scifi-fantasy.com

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: Tom Melly
Subject: Re: Calendar Macro [10.8kb]
Date: 22 Nov 2001 09:12:02
Message: <3bfd07b2@news.povray.org>
"Bill DeWitt" <bde### [at] cflrrcom> wrote in message
news:3bfc8c28$1@news.povray.org...
>
>     What I mean is do you have that system so that you can add it to your
> macro to allow it to read the system clock and maybe highlight today's
date
> or automatically make the right month unless you tell it otherwise? If not
I
> can tell you how to do it.
>

Ah! No, but it might be a nice option - I could implement it through a batch
file and pov i/o I suppose. I can't think of any cross-platform way apart
from using perl, but then that ties it to having perl installed. Would your
method be cross-platform?


Post a reply to this message

From: Tom Melly
Subject: Re: Calendar Macro [10.8kb]
Date: 22 Nov 2001 09:12:55
Message: <3bfd07e7$1@news.povray.org>
"blessing" <ble### [at] icefognet> wrote in message
news:3bfc5e3c@news.povray.org...
> intereting idea, now I have to make a nice background for mine.....
>

I've posted a better version to bin.scene-files...


Post a reply to this message

From: Bill DeWitt
Subject: Re: Calendar Macro [10.8kb]
Date: 22 Nov 2001 09:40:32
Message: <3bfd0e60@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote :
>
> Would your
> method be cross-platform?

    There are other platforms?

    I imagine that other platforms have ways of calling small batch programs
that write text files which contain the date and time. You have the pov.ini
run them, then read them in the pov script i/o functions. Including cross
platform instructions in the comments would make it cross platform.


Post a reply to this message

From: nospam
Subject: Re: Calendar Macro [10.8kb]
Date: 24 Nov 2001 16:33:20
Message: <3bfea719.14298978@localhost>
On Wed, 21 Nov 2001 18:52:58 +0100, "Jan Walzer" <jan### [at] lzernet>
wrote:

>The week starts with Monday!!!

Yup.  Sunday is the 7th day.  Even the bible has this correct.


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: Calendar Macro [10.8kb]
Date: 24 Nov 2001 16:52:52
Message: <3c0016b4$1@news.povray.org>
nospam schrieb in Nachricht <3bfea719.14298978@localhost>...
>On Wed, 21 Nov 2001 18:52:58 +0100, "Jan Walzer" <jan### [at] lzernet>
>wrote:
>
>>The week starts with Monday!!!
>
>Yup.  Sunday is the 7th day.  Even the bible has this correct.
>


Sorry, that's not correct. It's Saturday in the bible - as the Jews
celebrate it. Sunday as the day of the lord is caused by Easter and JC
resurrection.

Marc-Hendrik


Post a reply to this message

From: Anton Sherwood
Subject: Re: Calendar Macro [10.8kb]
Date: 25 Nov 2001 01:30:09
Message: <3C0091B0.E2CDEFDE@pobox.com>
> >On Wed, 21 Nov 2001 18:52:58 +0100, "Jan Walzer" <jan### [at] lzernet> wrote:
> >>The week starts with Monday!!!

quoth PeterC:
> >Yup.  Sunday is the 7th day.  Even the bible has this correct.

Marc-Hendrik Bremer wrote:
> Sorry, that's not correct. It's Saturday in the bible - as the Jews

(and a few Christians)

> celebrate it. Sunday as the day of the lord is caused by Easter and JC
> resurrection.

Well, I doubt that the Bible ever mentions "Saturday" or "Sunday" by
those names.  But it's clear, isn't it?, that the crucifixion (Good
Friday) was on the "day of preparation", i.e. the day before the "day of
rest" -- which is still called something like `sabbat' in some Romance
languages as well as Hebrew.

-- 
Anton Sherwood  --  http://www.ogre.nu/ (online again, Nov.19)


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: Calendar Macro [10.8kb]
Date: 25 Nov 2001 04:45:00
Message: <3c00bd9c$1@news.povray.org>
Anton Sherwood schrieb in Nachricht <3C0091B0.E2CDEFDE@pobox.com>...
>Well, I doubt that the Bible ever mentions "Saturday" or "Sunday" by
>those names.  But it's clear, isn't it?, that the crucifixion (Good
>Friday) was on the "day of preparation", i.e. the day before the "day of
>rest" -- which is still called something like `sabbat' in some Romance
>languages as well as Hebrew.


Of course, the bible does not mention those names, which are of
Latin-Germanic origin if I'm not mistaken (Thursday = Thor's day, Friday =
Freya's day etc.).

I may misunderstand you, but I was not talking about the crucifixion, but
the resurrection of J.C. which is celebrated each Sunday.
But to be honest: It is absolutely arbitrary which day one chooses to let
the week begin, isn't it?

Marc-Hendrik


Post a reply to this message

From: Ib Rasmussen
Subject: Re: Calendar Macro [10.8kb]
Date: 25 Nov 2001 05:30:51
Message: <3C00C867.A4C07136@ibras.dk>
Marc-Hendrik Bremer wrote:
> 
> But to be honest: It is absolutely arbitrary which day one chooses to let
> the week begin, isn't it?

Not if we want to keep on calling saturday/sunday the week-end. :-)

Anyway, there is a European Standard that specifies, that the week
starts on monday, so in Europe at least, it is official. Don't know
about the rest of the world.

/Ib


Post a reply to this message

From: Anton Sherwood
Subject: Re: Calendar Macro [10.8kb]
Date: 25 Nov 2001 06:13:23
Message: <3C00D412.1F9AAB7A@pobox.com>
>> ... it's clear, isn't it?, that the crucifixion (Good Friday) was on
>> the "day of preparation", i.e. the day before the "day of rest" ...

Marc-Hendrik Bremer wrote:
> I may misunderstand you, but I was not talking about the crucifixion,
> but the resurrection of J.C. which is celebrated each Sunday.

I'm no Bible expert; the crucifixion is the only link I know between the
ancient Jewish week and the modern week.  If the crucifixion was the day
before "the day of rest", then the resurrection must be the day after.


-- 
Anton Sherwood  --  http://www.ogre.nu/ (online again, Nov.19)


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: Calendar Macro [10.8kb]
Date: 25 Nov 2001 06:17:46
Message: <3c00d35a@news.povray.org>
Anton Sherwood schrieb in Nachricht <3C00D412.1F9AAB7A@pobox.com>...
>I'm no Bible expert; the crucifixion is the only link I know between the
>ancient Jewish week and the modern week.  If the crucifixion was the day
>before "the day of rest", then the resurrection must be the day after.


So we agree and I got you partly wrong.

Marc-Hendrik


Post a reply to this message

From: Bill DeWitt
Subject: Re: Calendar Macro [10.8kb]
Date: 25 Nov 2001 11:33:40
Message: <3c011d64@news.povray.org>
"Anton Sherwood" <bro### [at] poboxcom> wrote :
> I'm no Bible expert; the crucifixion is the only link I know between the
> ancient Jewish week and the modern week.  If the crucifixion was the day
> before "the day of rest", then the resurrection must be the day after.

    "On the third day he rose again", so could be the day after the day
after... depends on if you count the day he was buried as the first day or
not.

    But standard calendars have the week ends in their proper places, at
both ends of the week. The week starts at one end on Sunday and goes through
the other end which is Saturday.


Post a reply to this message

From: Anton Sherwood
Subject: Re: Calendar Macro [10.8kb]
Date: 25 Nov 2001 14:58:48
Message: <3C014F39.B1B44603@pobox.com>
> "Anton Sherwood" <bro### [at] poboxcom> wrote :
> > I'm no Bible expert; the crucifixion is the only link I know between the
> > ancient Jewish week and the modern week.  If the crucifixion was the day
> > before "the day of rest", then the resurrection must be the day after.

Bill DeWitt wrote:
>     "On the third day he rose again", so could be the day after the day
> after... depends on if you count the day he was buried as the first day
> or not.

Zero-based indexing is rare in the ancient world; that bit, at least, is
uncontroversial: the cross-raising was day 1 (Friday), the resurrection
day 3 (Sunday).


>     But standard calendars have the week ends in their proper places,
> at both ends of the week. The week starts at one end on Sunday and goes
> through the other end which is Saturday.

American standard, yes, but evidently not Eurostandard.

-- 
Anton Sherwood  --  http://www.ogre.nu/ (online again, Nov.19)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.