Oh ok sorry!
So yep tag it with systemConfig and it will become a plugin.
At the moment it is hardwired to look for a field called 'dob' and
'dod' on the tiddler it is called from.
These fields must have dates in the format YYYYMMDD.

How are you planning to use it?
Would you want it to work for the tiddler it is called from or would
you want to give it two dates as arguments? If the latter try the
following (untested) by doing <<age 20071201 20080302>>

The first two lines of the macro set where the date comes from. Don't
be scared to experiment by changing where they come from.
Hope my help was better this time :)
Jon

config.macros.age ={
    handler: function(place, macroName, params, wikifier, paramString,
tiddler){
        var d1 = params[0];
        var d2=  params[1];
       //var d1 = tiddler.fields["dob"];
       //var d2=  tiddler.fields["dod"];
        if(!d2){
            d2 = new Date().convertToLocalYYYYMMDDHHMM();
        }
        var y1 = parseInt(d1.substr(0,4));
        var y2 = parseInt(d2.substr(0,4));

        var m1 = parseInt(d1.substr(4,2));
        var m2 = parseInt(d2.substr(4,2));

        var day1 = parseInt(d1.substr(6,2));
        var day2 = parseInt(d2.substr(6,2));

        var ageY = y2-y1;
        var ageM = m2 - m1;
        if(m2 > m1){
            ageM = m2 - m1;
        }
        else if(m2 < m1){
            ageM = 12 -(m1- m2);
            ageY -=1;
        }

        var html =ageY + "years";
        if(ageM != 0){
             html+=" and "+ ageM+" months";
        }
        jQuery(place).html(html);

    }

};


On Oct 23, 2:36 pm, Tobbe <[email protected]> wrote:
> Hi,
>
> Ok :) thanks alot...but,
>
> I'm a novice you know. How do I use it in a tiddler? I've saved the
> macro/script as a new tiddler with the name AgeMacro and tagged it
> systemConfig (don't know if it has to). Can you give an example?
>
> Thanks again :)
>
> //Tobbe
>
> On 23 Okt, 14:41, rakugo <[email protected]> wrote:
>
> > Lucky for you I've been working on that for my family tree vertical.
> > Unfortunately only giving amount of months and years (not days).
> > The code is below - hope this is a good starting point.
> > Jon.
>
> > config.macros.age ={
> >     handler: function(place, macroName, params, wikifier, paramString,
> > tiddler){
> >         var d1 = tiddler.fields["dob"];
> >         var d2=  tiddler.fields["dod"];
> >         if(!d2){
> >             d2 = new Date().convertToLocalYYYYMMDDHHMM();
> >         }
> >         var y1 = parseInt(d1.substr(0,4));
> >         var y2 = parseInt(d2.substr(0,4));
>
> >         var m1 = parseInt(d1.substr(4,2));
> >         var m2 = parseInt(d2.substr(4,2));
>
> >         var day1 = parseInt(d1.substr(6,2));
> >         var day2 = parseInt(d2.substr(6,2));
>
> >         var ageY = y2-y1;
> >         var ageM = m2 - m1;
> >         if(m2 > m1){
> >             ageM = m2 - m1;
> >         }
> >         else if(m2 < m1){
> >             ageM = 12 -(m1- m2);
> >             ageY -=1;
> >         }
>
> >         var html =ageY + "years";
> >         if(ageM != 0){
> >              html+=" and "+ ageM+" months";
> >         }
> >         jQuery(place).html(html);
>
> >     }
>
> > };
>
> > On Oct 23, 12:38 pm, Tobbe <[email protected]> wrote:
>
> > > Hi,
>
> > > I'm searching for a method to view a persons age in a tiddler. Let's
> > > say the person whas bord 20 apr 1645 and died 30 nov 1715. How old is
> > > that person in years, month and days? Even if the person is still
> > > alive today it should show the persons present age.
>
> > > TIA.
>
> > > //Tobbe
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to