On Saturday, February 22, 2014 7:18:01 PM UTC-8, Anton Aylward wrote: > > I'd really like to be able to enter dates as the three fields, day month > year, and have that converted when I press 'done' but I'm not figuring this > out. Its going to take JavaScript programming, isn't it? I haven't found > any example to cut-and-paste. A popup/select for "month" might be asking > too much. >
After some more thought, it occurs to me that you might avoid the entire date conversion issue entirely: The use-case you've outlined needs to support entering, storing, displaying, and sorting by dates... but does not need to perform *calculations* on the date values themselves (e.g., given two dates, computing a 'relative date' such as "3 years, 2 months ago"). If you use separate tiddler fields to enter/store the desired day/month/year/epoch information as simple text strings, then you can use standard TWCore mechanisms, like this: EditTemplate: day:<span class="twochar" macro="edit day"></span>month:<span class= "twochar" macro="edit month"></span>year:<span class="fourchar" macro="edit year"></span>epoch:<span class="threechar" macro="edit epoch"></span> ViewTemplate: Date: <span macro="view day"></span>/<span macro="view month"></span>/<span macro="view year"></span><span macro="view epoch"></span> Note that, while there are no formal restrictions on the input format of the individual values, you will most likely want to use numeric values only, with leading zeros for single digit values (e.g., use "07" instead of "7") so that a simple *text* sort will result in proper "numeric" ordering as well. Also note the use of CSS classnames "twochar", "threechar" and "fourchar". These classes let you limit the length of the input fields display in the edit mode form so that they are only as big as needed (the default size is 20 or 30 characters!). You can find these class definitions here: http://www.TiddlyTools.com/#StyleSheetShortcuts Another issue is creating *properly* sorted lists of tiddlers as output that allows for the reverse ordering of BCE vs CE year numbers. But it's not really all that complex... instead of writing something like: <<list filter [sort[dateline]]>> and leaving it up to javascript "date magic" to do the right thing (which we know it does NOT!)... you would need to sort by more than one field and use more than one <<list>> macro, like this: <<list filter [epoch[BCE]][sort[-year]][sort[month]][sort[day]]>> <<list filter [epoch[CE]][sort[year]][sort[month]][sort[day]]>> The first part of the filter selects only tiddlers for which the 'epoch' field has the indicated value (BCE or CE), and then sorts those tiddler according to their year/month/day. Note the leading "-" on the BCE year sort... that reverses the order of those years, just as needed! Similarly, if you were planning to use a plugin such as ForEachTiddlerPlugin or InlineJavascriptPlugin to access the custom "dateline" field, then you would need to access the values in all the date-related fields (day,month,year,epoch) and then perhaps concatenate to produce a single text string before further processing. But we can leave that discussion for another time. Hopefully, the above will get you most of the way there... and you won't need anything more complicated. enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios YOUR DONATIONS ARE VERY IMPORTANT! HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... http://TiddlyTools.github.com/fundraising.html#MakeADonation Professional TiddlyWiki Consulting Services... Analysis, Design, and Custom Solutions: http://www.TiddlyTools.com/#Contact -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.

