Looking for specific Date function.
|
|
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
02-07-2009 14:57
I'm looking for a specific Date function that, given a time in seconds, it returns Day, Month and Year. For example today is Saturday: integer timeLeft = 86400; //24hs list dateData = returnDate(timeLeft); The result of the list should be: ["2009","February","Sunday"]; If someone has something that could look like this please share it... otherwise I will have to write it by myself and I'll post the solution here 
_____________________
Jocko Domo japanese goods [Blog]
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
02-07-2009 15:10
I haven't played with them at all, but I notice that there are a few sample scripts on the LSL wiki at  that come fairly close to what you want to do ..... at least close enough to save you some coding trouble.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
02-07-2009 17:15
There is no calendar function in LSL. While you can get the current date with a couple of different calls, to get the day of week/date for a different day you will need to create your own calendar taking into account days per month and leap year etc.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
|
02-07-2009 17:19
/54/45/302481/1.html might be of some value.
_____________________
-
So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.
I can be found on the web by searching for "SuezanneC Baskerville", or go to
http://www.google.com/profiles/suezanne
-
http://lindenlab.tribe.net/ created on 11/19/03.
Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard, Robin, and Ryan
-
|
|
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
02-08-2009 05:23
I suppose I'll have to do it by myself...there should be default Calendar functions in LSL, almost every programming language have them.
_____________________
Jocko Domo japanese goods [Blog]
|
|
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
|
02-08-2009 07:03
Looks to me like the last example in Rollig's wiki link above will only take minor tampering to do what you want.
_____________________
-
So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.
I can be found on the web by searching for "SuezanneC Baskerville", or go to
http://www.google.com/profiles/suezanne
-
http://lindenlab.tribe.net/ created on 11/19/03.
Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard, Robin, and Ryan
-
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-08-2009 08:53
http://en.wikipedia.org/wiki/Perpetual_calendar has a good formula for grabbing the day of the week for dates 1901-2099 //-- how you fill these three is up to you, llGetDate works, but you may want timestamp to get a correct hour offset. integer gIntYear; integer gIntMonth; integer gIntDayOfMonth;
//-- month names included so you can print the friendly name list gLstMonth = ["January", 0, "February", 3, "March", 3, "April", 6, "May", 1, "June", 4, "July", 6, "August", 2, "September", 5, "October", 0, "November", 3, "December", 5]; list gLstDOW = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
integer vIntDOW = gIntYear + (integer)(gIntYear / 4.0) + llList2Integer(gLstMonth, gIntMonth * 2 + 1) + gIntDayOfMonth - 2; if ( !(gIntYear % 4) && gIntMonth < 2){ gIntDOW -= 1; } llSay( 0, lList2String( gLstDOW, gIntDOW ) + ", " + lllList2String( gLstMonth, gIntMonth * 2) + " " + (string)gIntDayOfMonth + ", " + (string)gIntYear );
ETA: minor typo + correction in leap year formula
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-08-2009 11:32
I started some work on this kind of thing here: /54/45/302481/1.htmlIt includes functions that will return the day of the week for ANY valid Gregorian date ('weekdayOfDay' and 'weekdayOfDate'). You could also use 'daysBetween' or 'daysBetweenDates' to do the opposite calculation: how many days between "the epoch" and a particular date (times 86400 of course to get seconds). It doesn't deal with leap-seconds, but few applications need to be THAT precise. I'll see if I can work up a solution for this kind of problem as well and add it to that library. And maybe get it over to the wiki at some point. LOL.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-08-2009 16:51
I just added some functions to the thread I linked to above. In particular, the 'daysAfter' or 'daysAfterDate' functions may be of help, though for this particular application you'll have to include in your own code the definition of "the epoch" and the logic to convert seconds to days.
I haven't compiled or tested that addition yet. I'll be working on that over the next couple of days. Just wanted to let you know it's there and might (now or eventually) be of help. Heck, it might even just work. If you want to help test it, that's always appreciated.
|
|
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
02-12-2009 11:42
Thanks Hewee!, this solves my problem.
_____________________
Jocko Domo japanese goods [Blog]
|