Convert real date to Sosarian one?

Post your Custom Scripts or Packages.

Moderator: POL Developer

Post Reply
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am
Location: Italy

Convert real date to Sosarian one?

Post 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"
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am
Location: Italy

Re: Convert real date to Sosarian one?

Post by xeon »

Up

I found the instructions (http://uo.stratics.com/content/basics/datetime.shtml), I'm just too lazy :P
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Convert real date to Sosarian one?

Post 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
Post Reply