Page 1 of 1

Convert real date to Sosarian one?

Posted: Wed Jun 08, 2011 11:50 am
by xeon
Hi, has anyone a script which fetch the Sosarian date, maybe given in input the systime?
Hi mean function UODate(input) -> "23 Misericordia 523"

Re: Convert real date to Sosarian one?

Posted: Mon Jun 13, 2011 12:50 pm
by xeon
Up

I found the instructions (http://uo.stratics.com/content/basics/datetime.shtml), I'm just too lazy :P

Re: Convert real date to Sosarian one?

Posted: Thu Jun 16, 2011 1:22 pm
by CWO
sloppy script, it worked when I used it and seemed to sync up well with that page you linked.. but I can't guarantee it'll be 100% accurate...

from tests on this script, there is no possible way UO was released in 289... it had to be in 314 because 289 is somewhere back in 1993 from every calculation I did...

Code: Select all

function GetSosariaTimeDate(who, time := 0)
	var monthname:={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
	var seconds := polcore().systime + 3600;
	if (time)
		seconds := time;
	endif
	var day := (seconds/7200) + 153525; // Sosaria's time started before UNIX but don't add it to systime because its a signed int and will go negative :-)
	var month := 1 + (day/73);
	var year := month/12;
	month := month%12;
	day := day%73;
	if (!day)
		month := month - 1;
		day := 73;
	endif
	if (month == -1)
		month := 12;
		year := year - 1;
	elseif (month == 0)
		month := 1;
	endif
	if (day == 0)
		day := 1;
	endif
	var currenttime := (seconds%7200) * 12;
	var hours := currenttime/3600;
	if (hours < 10)
		hours := "0" + CStr(hours);
	endif
	var minutes := (currenttime%3600)/60;
	if (minutes < 10)
		minutes := "0" + CStr(minutes);
	endif
	seconds := (currenttime%3600)%60;
	if (seconds < 10)
		seconds := "0" + CStr(seconds);
	endif
	SendSysMessage(who, CStr(monthname[month]) + " " + CStr(day) + ", " + CStr(year));
	SendSysMessage(who, CStr(hours) + ":" + CStr(minutes) + ":" + CStr(seconds));
endfunction