[tw] Re: age calculation from date of birth

2009-05-18 Thread Dave Parker

Ok, for sake of completion, and for anyone else who might be looking
for this someday, here's what worked for me.  Its a modification of
something Udo B wrote for someone a while back, and FND recently
helped me with the rounding.  So someone with a Date of Birth
2000-01-01 should read as 9.4 years old.

Its a FET that looks at the date of birth which is stored in the title
of a tiddler, and that tiddler has a tag called Age (which for
convenience I've also titled the tiddler that contains this FET.:

forEachTiddler
where
'tiddler.tags.contains(Age)'

sortBy
'(tiddler.title)'

script '

// Returns the first line of the string
//
function getFirstLine(s) {
var m = s.match(/\s*(.*)/);
return m != null  m.length = 1 ? m[1] : ;
}

// Returns the number of days between two dates.
//
// Only the year,month and day of the dates are considered.
//
// if date2  date1 the result will be negative.
//
function getDaysBetween(date1, date2) {
date1 = new 
Date(date1.getFullYear(),date1.getMonth(),date1.getDate
());
date2 = new 
Date(date2.getFullYear(),date2.getMonth(),date2.getDate
());
return ((date2.getTime()-date1)/8640).toFixed();
}

// Returns the date given by the string s
//
// @param s String of format -MM-DD (- may be 
any char)
// @param defaultValue  returned when s is not a valid date.
//
// @return a Date object representing the given date.
//
function parseDate(s, defaultValue) {
try {
return new Date(parseInt(s.substr(0,4),10),
parseInt(s.substr(5,2),10)-1,
parseInt(s.substr(8,2),10));
} catch(e) {
return defaultValue;
}
}

function getYearsLeftText(tiddler) {
return Math.round(((getDaysBetween(new Date(),parseDate
(tiddler.title, new Date(/-365)*10)/10+ years old;
}
'

write
'getYearsLeftText(tiddler)+\n'



-Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to TiddlyWiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: age calculation from date of birth

2009-05-16 Thread Dave Parker

I found a reminder format for birthdays in the following:

reminder format:ANNIVERSARY month:01 day:01 firstyear:2000

which gives the correct number (9)

but when you do it with this date:

reminder format:ANNIVERSARY month:11 day:01 firstyear:2000

it still says (9)

Seeing as today's date is between the two I'd expect the second to
display (8)



Does anyone know what I'm doing wrong?

Thanks,
-Dave


On Apr 17, 10:09 pm, Dave Parker cedar...@telus.net wrote:
 Thanks Mike, I think I'll try playing with the reminder plugin and see
 if I can tweak it to go backwards (although I don't really know what
 I'm doing)  I'll post back later if it works.

 Dave

 On Apr 17, 9:45 pm, Mike eris...@gmail.com wrote:



  I haven't tried this - but 
  maybehttp://www.tiddlytools.com/#TiddlerTweakerPlugin
  You could try setting the creation date of the tiddler as the starting
  date (birthday)

  Good Luck,

  Mike

  (Let me know if that works -.- otherwise beyond my understanding)

  On Apr 17, 10:01 pm, Dave Parker cedar...@telus.net wrote:

   thanks Mike and M), I could use both of these.

    As I'm looking to make use of the calendar/date/reminder plugins I'd
   like to get that one going.

   When you do the newReminder in the example, it only gives you the
   current year and future years, not previous years.  Do you (or anyone)
   happen to know how to get it to go either forward or backward in time?

   thanks,

   Dave

   On Apr 17, 8:27 pm, Mike eris...@gmail.com wrote:

newReminder
Should give you a drop down list to set the date
For an annual occurrence try:
reminder month:09 day:20 title:~TiddlyWiki's First Release
Anniversary firstyear:2004
Which adds the first year syntax and gives a total years = 5
showReminders
Also lists your upcoming reminders. . .

Some more 
examples:http://remindermacros.tiddlyspot.com/#[[Simple%20examples]]http://remindermacros.tiddlyspot.com/#showRemindersSyntax
(Click edit to see the code)

Not sure how familiar with TW you are, let me know if that gets you
started.

Good Luck,

Mike

On Apr 17, 7:02 pm, M) marc.bu...@gmail.com wrote:

 Not quite what you are after, but you can use scriptvar a=new Date
 ();document.write(a.getFullYear()-1919);/script 
 withhttp://www.tiddlytools.com/#InlineJavascriptPlugin.  
 Remindermacros
 has something similar though with significantly more features.

 M)

 On Apr 17, 3:47 pm, Dave Parker cedar...@telus.net wrote:

  Hi,

  does anyone know how to display in one tiddler a personsage, based 
  on
  the contents of a tiddler called DateOfBirth?

  I've looked at maybe usinghttp://remindermacros.tiddlyspot.com/but
  can't figure it out.

  thanks,
  Dave Parker- Hide quoted text -

- Show quoted text -- Hide quoted text -

  - Show quoted text -- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to TiddlyWiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: age calculation from date of birth

2009-04-17 Thread M)

Not quite what you are after, but you can use scriptvar a=new Date
();document.write(a.getFullYear()-1919);/script with
http://www.tiddlytools.com/#InlineJavascriptPlugin.  Remindermacros
has something similar though with significantly more features.

M)

On Apr 17, 3:47 pm, Dave Parker cedar...@telus.net wrote:
 Hi,

 does anyone know how to display in one tiddler a persons age, based on
 the contents of a tiddler called DateOfBirth?

 I've looked at maybe usinghttp://remindermacros.tiddlyspot.com/but
 can't figure it out.

 thanks,
 Dave Parker
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to TiddlyWiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: age calculation from date of birth

2009-04-17 Thread Dave Parker

thanks Mike and M), I could use both of these.

 As I'm looking to make use of the calendar/date/reminder plugins I'd
like to get that one going.

When you do the newReminder in the example, it only gives you the
current year and future years, not previous years.  Do you (or anyone)
happen to know how to get it to go either forward or backward in time?

thanks,

Dave

On Apr 17, 8:27 pm, Mike eris...@gmail.com wrote:
 newReminder
 Should give you a drop down list to set the date
 For an annual occurrence try:
 reminder month:09 day:20 title:~TiddlyWiki's First Release
 Anniversary firstyear:2004
 Which adds the first year syntax and gives a total years = 5
 showReminders
 Also lists your upcoming reminders. . .

 Some more 
 examples:http://remindermacros.tiddlyspot.com/#[[Simple%20examples]]http://remindermacros.tiddlyspot.com/#showRemindersSyntax
 (Click edit to see the code)

 Not sure how familiar with TW you are, let me know if that gets you
 started.

 Good Luck,

 Mike

 On Apr 17, 7:02 pm, M) marc.bu...@gmail.com wrote:



  Not quite what you are after, but you can use scriptvar a=new Date
  ();document.write(a.getFullYear()-1919);/script 
  withhttp://www.tiddlytools.com/#InlineJavascriptPlugin.  Remindermacros
  has something similar though with significantly more features.

  M)

  On Apr 17, 3:47 pm, Dave Parker cedar...@telus.net wrote:

   Hi,

   does anyone know how to display in one tiddler a persons age, based on
   the contents of a tiddler called DateOfBirth?

   I've looked at maybe usinghttp://remindermacros.tiddlyspot.com/but
   can't figure it out.

   thanks,
   Dave Parker- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to TiddlyWiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: age calculation from date of birth

2009-04-17 Thread Mike

I haven't tried this - but maybe 
http://www.tiddlytools.com/#TiddlerTweakerPlugin
You could try setting the creation date of the tiddler as the starting
date (birthday)

Good Luck,

Mike

(Let me know if that works -.- otherwise beyond my understanding)

On Apr 17, 10:01 pm, Dave Parker cedar...@telus.net wrote:
 thanks Mike and M), I could use both of these.

  As I'm looking to make use of the calendar/date/reminder plugins I'd
 like to get that one going.

 When you do the newReminder in the example, it only gives you the
 current year and future years, not previous years.  Do you (or anyone)
 happen to know how to get it to go either forward or backward in time?

 thanks,

 Dave

 On Apr 17, 8:27 pm, Mike eris...@gmail.com wrote:

  newReminder
  Should give you a drop down list to set the date
  For an annual occurrence try:
  reminder month:09 day:20 title:~TiddlyWiki's First Release
  Anniversary firstyear:2004
  Which adds the first year syntax and gives a total years = 5
  showReminders
  Also lists your upcoming reminders. . .

  Some more 
  examples:http://remindermacros.tiddlyspot.com/#[[Simple%20examples]]http://remindermacros.tiddlyspot.com/#showRemindersSyntax
  (Click edit to see the code)

  Not sure how familiar with TW you are, let me know if that gets you
  started.

  Good Luck,

  Mike

  On Apr 17, 7:02 pm, M) marc.bu...@gmail.com wrote:

   Not quite what you are after, but you can use scriptvar a=new Date
   ();document.write(a.getFullYear()-1919);/script 
   withhttp://www.tiddlytools.com/#InlineJavascriptPlugin.  Remindermacros
   has something similar though with significantly more features.

   M)

   On Apr 17, 3:47 pm, Dave Parker cedar...@telus.net wrote:

Hi,

does anyone know how to display in one tiddler a persons age, based on
the contents of a tiddler called DateOfBirth?

I've looked at maybe usinghttp://remindermacros.tiddlyspot.com/but
can't figure it out.

thanks,
Dave Parker- Hide quoted text -

  - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to TiddlyWiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: age calculation from date of birth

2009-04-17 Thread Dave Parker

Thanks Mike, I think I'll try playing with the reminder plugin and see
if I can tweak it to go backwards (although I don't really know what
I'm doing)  I'll post back later if it works.

Dave

On Apr 17, 9:45 pm, Mike eris...@gmail.com wrote:
 I haven't tried this - but 
 maybehttp://www.tiddlytools.com/#TiddlerTweakerPlugin
 You could try setting the creation date of the tiddler as the starting
 date (birthday)

 Good Luck,

 Mike

 (Let me know if that works -.- otherwise beyond my understanding)

 On Apr 17, 10:01 pm, Dave Parker cedar...@telus.net wrote:



  thanks Mike and M), I could use both of these.

   As I'm looking to make use of the calendar/date/reminder plugins I'd
  like to get that one going.

  When you do the newReminder in the example, it only gives you the
  current year and future years, not previous years.  Do you (or anyone)
  happen to know how to get it to go either forward or backward in time?

  thanks,

  Dave

  On Apr 17, 8:27 pm, Mike eris...@gmail.com wrote:

   newReminder
   Should give you a drop down list to set the date
   For an annual occurrence try:
   reminder month:09 day:20 title:~TiddlyWiki's First Release
   Anniversary firstyear:2004
   Which adds the first year syntax and gives a total years = 5
   showReminders
   Also lists your upcoming reminders. . .

   Some more 
   examples:http://remindermacros.tiddlyspot.com/#[[Simple%20examples]]http://remindermacros.tiddlyspot.com/#showRemindersSyntax
   (Click edit to see the code)

   Not sure how familiar with TW you are, let me know if that gets you
   started.

   Good Luck,

   Mike

   On Apr 17, 7:02 pm, M) marc.bu...@gmail.com wrote:

Not quite what you are after, but you can use scriptvar a=new Date
();document.write(a.getFullYear()-1919);/script 
withhttp://www.tiddlytools.com/#InlineJavascriptPlugin.  Remindermacros
has something similar though with significantly more features.

M)

On Apr 17, 3:47 pm, Dave Parker cedar...@telus.net wrote:

 Hi,

 does anyone know how to display in one tiddler a persons age, based on
 the contents of a tiddler called DateOfBirth?

 I've looked at maybe usinghttp://remindermacros.tiddlyspot.com/but
 can't figure it out.

 thanks,
 Dave Parker- Hide quoted text -

   - Show quoted text -- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to TiddlyWiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~--~~~~--~~--~--~---