Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dates

Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
01-11-2010 21:13
Is there a way to have a script off set the days on a gettime stamp? I'm trying to offset it so it picks up the months to as well.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-11-2010 22:08
wrong forum (you probably wanted scripting tips), but yes, it's easiest with the llGetUnixTime() function, just add/subtract 3600 for each hour you wish to offset and 86400 for each day. alternatively you can use the same format as llGetTimestamp and break it down. the following will help you get days of each month, for any given year, so you can count by days with proper month rollovers

CODE

integer uMonthDaysInt( vIntYear, vIntMonth ){
return (30 | (vIntMonth & 1) ^ (vIntMonth > 7)) - ((vIntMonth == 2) + !(vIntYear & 3));
} //-- fails on february 1900, and 2100, months between then are accurate.


this may also be helpful, it'll give you the weekday for a given year/month/day

CODE

string uWeekdayStr( integer vIntYear, integer vIntMonth, integer vIntDay ){
return llList2String ( ["Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"],
(vIntYear + (vIntYear >> 2) - ((vIntMonth < 3) & !(vIntYear & 3)) + vIntDay
+ (integer)llGetSubString( "_033614625035", vIntMonth, vIntMonth )) % 7 );
}


unfortunately I can't find the converter I wrote for Unix dates to readable dates, but I suggest subtracting out 2 years to get a base leap year before trying to calculate further

Ps please direct further inquiries to the scripting tips forum

ETA:
sorry I misread the original post as being about getting the day of the week, I've edited this post to address the OP
_____________________
|
| . "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...
| -
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-12-2010 16:55
EDIT: *UPDATE*

both improved functions to convert arbitrary timestamps to and from Unix time codes are now available on the LSL Portal
http://wiki.secondlife.com/wiki/User:Void_Singer/Functions#Timestamp:_Converters
_____________________
|
| . "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...
| -