Hi Tobias,

Thanks for looking.
In fact the two lines :

$tw.wiki.setText("$:/_frd/state/calendar","year","",year);
$tw.wiki.setText("$:/_frd/state/calendar","month","",month);

work well in a regular widget (I've tested it). So does my zeropad function.
So it's probably a "startup module" thing ...

I'll try to change some parameters or wait for someone who knows better to 
jump in ...

FrD

Le mercredi 7 octobre 2015 18:40:36 UTC+2, Tobias Beer a écrit :
>
> Hi Frd,
>
> I have no experience with startup modules, but the core has a 
> $tw.utils.pad(value) method.
>
> So this...
>
> exports.startup = function() {
>>     var date= new Date();
>>     var year=date.getFullYear();
>>     var month=zeropad(date.getMonth() +1);
>>     $tw.wiki.setText("$:/_frd/state/calendar","year","",year);
>>     $tw.wiki.setText("$:/_frd/state/calendar","month","",month);
>> };
>>
>> function zeropad(num) {
>>     var s= "0"+num.toString()+"0";
>>     return s.slice(-3,-1);
>> }
>>
>
> Could just be...
>
> exports.startup = function() {
>     var date= new Date();
>     $tw.wiki.setText("$:/_frd/state/calendar", "year", undefined, date.
> getFullYear());
>     $tw.wiki.setText("$:/_frd/state/calendar", "month", undefined, $tw.
> utils.pad(date.getMonth()+1));
> };
>
> I can imagine that using undefined rather than "" as the third parameter 
> to setText() perhaps makes a difference.
> A quick test suggests the above works, yay.
>
> Wait, checking again, I see it even worked without my mods.
> Did you perhaps not look at the fields but just saw an empty tiddler? ;-)
>
> Best wishes,
>
> — tb
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f21bacab-2801-4712-8731-2fb1d0939c02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to