Convert real date to Sosarian one?

Post your Custom Scripts or Packages.

Moderator: POL Developer

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

Convert real date to Sosarian one?

Post by xeon » Wed Jun 08, 2011 11:50 am

Hi, has anyone a script which fetch the Sosarian date, maybe given in input the systime?
Hi mean function UODate(input) -> "23 Misericordia 523"
Scripter Xeon | Zulu Hotel Italia 7th Age | www.zhi.it
Image

xeon
Forum Regular
Posts: 332
Joined: Fri Oct 31, 2008 3:18 am
Location: Italy
Contact:

Re: Convert real date to Sosarian one?

Post by xeon » Mon Jun 13, 2011 12:50 pm

Up

I found the instructions (http://uo.stratics.com/content/basics/datetime.shtml), I'm just too lazy :P
Scripter Xeon | Zulu Hotel Italia 7th Age | www.zhi.it
Image

User avatar
CWO
POL Expert
Posts: 1130
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA
Contact:

Re: Convert real date to Sosarian one?

Post by CWO » Thu Jun 16, 2011 1:22 pm

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

Who is online

Users browsing this forum: No registered users and 2 guests