I just stumbled on an easy way to turn the local date and time into Squiffy attributes:
[[Calculate the Date]]:
squiffy.set("longdate", new Date());
squiffy.set("date", new Date().toDateString());
squiffy.set("year", new Date().getFullYear());
squiffy.set("jmonth", new Date().getMonth());
squiffy.set("datenum", new Date().getDate());
squiffy.set("wkdynum", new Date().getDay());
squiffy.set("milhour", new Date().getHours());
squiffy.set("minutes", new Date().getMinutes());
{@hour=@milhour}{if milhour>12:{@hour-=12}} //Turns military time into 12 hour AM/PM time.
{if milhour< 12:{@AMPM=AM}} {if milhour> 11:{@AMPM=PM}} //Tells Squiffy when to use AM or PM
{if minutes<10:{@0=0}}{else:{@0=}} //Puts a zero in front of minutes less than 10
{@month=@jmonth}{@month+=1} //Changes January from month number 0 to month number 1
{if month=1:{@Month=January}}{if month=2:{@Month=February}}{if month=3:{@Month=March}}{if month=4:{@Month=April}}{if month=5:{@Month=May}}{if month=6:{@Month=June}}{if month=7:{@Month=July}}{if month=8:{@Month=August}}{if month=9:{@Month=September}}{if month=10:{@Month=October}}{if month=11:{@Month=November}}{if month=12:{@Month=December}} //Tells Squiffy the name for each month number (January - December).
{if wkdynum=1:{@xday=Monday}}{if wkdynum=2:{@xday=Tuesday}}{if wkdynum=3:{@xday=Wednesday}}{if wkdynum=4:{@xday=Thursday}}{if wkdynum=5:{@xday=Friday}}{if wkdynum=6:{@xday=Saturday}}{if wkdynum=7:{@xday=Sunday}} //Tells Squiffy the name of each numbered day (Monday to Sunday).
{if datenum=1:{@th=st}}{if datenum=21:{@th=st}}{if datenum=31:{@th=st}}
{if datenum=2:{@th=nd}}{if datenum=22:{@th=nd}}
{if datenum=3:{@th=rd}}{if datenum=23:{@th=rd}}
{if datenum<>1:{if datenum<>21:{if datenum<>31:{if datenum<>2:{if datenum<>22:{if datenum<>3:{if datenum<>23:{@th=th}}}}}}}} //Tells Squiffy how to do ordinals (1st, 21st, 31st, etc, 2nd, 22nd, 3rd, 23rd).
[[Todays Date]]
[[Todays Date]]:
{longdate}
{date}
{year}
{Month} ({month})
{datenum}{th}
{xday} ({wkdynum})
{hour}:{0}{minutes} {AMPM}
It's {hour}:{0}{minutes} {AMPM} on {xday}, {Month} {datenum}{th}, {year}.
So what other factual data can javascript get from the internet and teach Squiffy? Anybody know?
With the geolocation api of HTML5 you can determine the location of the player and then e.g. integrate the current weather there in the game
Wow, Pertex! That sounds very cool. You wouldn't happen to have a code sample, would you?