OK, I've kind of made progress with this one, with some of the answers
(sort of)...

Firstly, I've resorted to just entering data in the forms in the same
format and I've chosen "YYYY.MM.DD" as the standard format, that way
when the foreachtiddler macro (or any other macro for that matter)
runs that date strings are sorted correctly.

Secondly, when I output results, everynow and then I would like
something that formats better than "YYYY.MM.DD".  So based on the
responses and links above I came up with a transclusion script in a
Tiddler called "ReturnDateType" which looks like:
<script>
var strDate = "$1";
var arrDate = strDate.split(".");
var nYear, nMonth, nDay
nYear = +arrDate[0];
nMonth = +arrDate[1]-1;
nDay = +arrDate[2];
var datNew = new Date(nYear, nMonth, nDay);
var month_names = new Array ( );
month_names[month_names.length] = "Jan";
month_names[month_names.length] = "Feb";
month_names[month_names.length] = "Mar";
month_names[month_names.length] = "Apr";
month_names[month_names.length] = "May";
month_names[month_names.length] = "Jun";
month_names[month_names.length] = "Jul";
month_names[month_names.length] = "Aug";
month_names[month_names.length] = "Sep";
month_names[month_names.length] = "Oct";
month_names[month_names.length] = "Nov";
month_names[month_names.length] = "Dec";
return month_names[nMonth] + "-" + nYear;
</script>

Then when I call it in another tiddler as:
<<tiddler ReturnDateType with:{{tiddler.data("startdate")}}>>
...I get a simply formatted date the way I want it e.g. ("Feb-2009")

But what if I want this format output in part of the foreachtiddler?

I tried:
<<forEachTiddler
 where
 'tiddler.tags.contains("Projects") && tiddler.created'
 sortBy
 'tiddler.data("startdate")'
 descending
 write
 '"*"+tiddler.data("projectnumber")+" [[" +tiddler.title+"]]
("+<<tiddler ReturnDateType with:{{tiddler.data("startdate")}}$))+")"
+ "\n"'
>>

But it doesn't seem to work.  Perhaps you can't call a macro that
calls a transclusion from within a macro?

Any ideas?

Cheers

Trent


On Jan 19, 9:42 am, yardbird <[email protected]> wrote:
> Thanks Alan,
> I just tried this, but it didn't seam to help any.  Even though I've
> defined it as type=date in the template tiddler, specifically
>
> "<input name=startdate type=date style="width:100%" />"
>
> When you look at the actual tiddler created the data still seems to be
> stored as a string.  ie you get:
>
> <<formTiddler ProjectTemplate>><data>
> {"projectnumber":"QE09604","startdate":"04/09/2009","closedate":"01/02/2010"}
> </data>
>
> So I still thing I need to find some sort of way to convert the date
> into a recognised date.
>
> Alternatively perhaps I need to think about being restrictive in the
> form about the way dates are entered and force people to select a day,
> then month then year, so I can define a format such as YYYY.MM.DD that
> when sorted will sort properly.
>
> How do other people manage date fields?
>
> Cheers
>
> Trent
>
> On Jan 19, 12:29 am, AlanBCohen <[email protected]> wrote:
>
> > If you are using FormTiddlerPlugin (or some other technique) to define
> > HTML forms for data input and retrieval, then this may be helpful;
> > instead of defining the field type="text", use type="date".
> > As referred to athttp://dev.w3.org/html5/markup/input.date.html
> >     "Specifies that its input element is a control for setting the
> > element’s value to a string representing a date."
> > I haven't tried it myself since I'm not currently using any date
> > fields in my forms; but the docs on ForTiddlerPlugin say you can use
> > any valid HTML field.
> > Alan
-- 
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