RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RunUO 1.0 Final] UODateTime

Arek

Sorceror
[RunUO 1.0 Final] UODateTime

RunUO Versions:
This script was designed on RunUO 1.0. I have tested it with RunUO 2.0 SVN 57, and it works very well. It should also work with 2.0 RC1, but I don't have a copy installed. There is no reason it shouldn't work with newer versions of RunUO, or with any of its forks, since UODateTime doesn't rely on anything from RunUO (it only relies on the System namespace, as a matter of fact). Please note, however, that you will get no support on these forums if you use a modified RunUO core, and I will not personally support my modified Clocks.cs on a modified core, although I might support UODateTime.cs on one, if I'm in a good mood. :)

Features:
This script provides in-game britannian Dates and Times, accurate to the nearest Earth second. It is meant to be used as an in-game calendar and/or to mark items with an in-game time and/or date.

Installation:

Unzip UODateTime.zip into your Scripts folder - This will place the files readme.txt, COPYING, UODateTime.cs and Clocks.cs.disabled in Scripts\Arek

Optional - Rename Clocks.cs.disabled to Clocks.cs and move it to Scripts\Items\Skill Items\Tinkering, overwriting the existing file. This will make all in-game clocks report the time in sync with the date, however it removes timezone support (crappy imo anyway), so you do this at your own discretion. I may add timezone support later if there's enough demand for it. Look inside this file for a rather crappy example of how to get the current date and time.

Usage:

To the top of any script needing to access this add:

Code:
using Arek.UODateTime

You can then access this by using any of the following methods (all are static):
  • UODateTime.UOTimeStamp( [System.DateTime time] ) - Returns the number of Earth seconds since UO Started* - if a DateTime object is provided, use that instead of System.DateTime.Now (long)
  • UODateTime.Year( [long uoTimeStamp] ) - Returns the UO Year represented by uoTimeStamp, or the current UO Year if no timestamp is provided(int).
  • UODateTime.Month( [long uoTimeStamp] ) - Returns the UO Month represented by uoTimeStamp, or the current UO Month if no timestamp is provided (int) Range: 1-12
  • UODateTime.Day( [long uoTimeStamp] ) - Returns the UO Day represented by uoTimeStamp, or the current UO Day if no timestamp is provided (int) Range: 1-73
  • UODateTime.Hour( [long uoTimeStamp] ) - Returns the UO Hour represented by uoTimeStamp, or the current UO Hour if no timestamp is provided (int) Range: 0-23
  • UODateTime.Minute( [long uoTimeStamp] ) - Returns the UO Minute represented by uoTimeStamp, or the current UO Minute if no timestamp is provided (int) Range: 0-59
  • UODateTime.MonthString( [long uoTimeStamp] ) - Returns a string representing the UO Month represented by uoTimeStamp, or the current Month if no timestamp is provided (names same as Earth months).
  • UODateTime.TimeString( [long uoTimeStamp] ) - Returns a string representing the UO Time represented by uoTimeStamp, or the current time if no timestamp is provided (HH:MM, 24-hour format, for now).
  • UODateTime.HoursPassed( long tsFrom [,long tsTo] ) - Returns the amount of time, in UO Hours, that has passed since tsFrom until tsTo, or Now if tsTo is not provided (long).
  • UODateTime.DaysPassed( long tsFrom [,long tsTo] ) - Same as above, in Days (long).
  • UODateTime.MonthsPassed( long tsFrom [,long tsTo] ) - Same as above, in Months (long).
  • UODateTime.YearsPassed( long tsFrom [,long tsTo] ) - Same as above, in Years (long).

You do not need to instantiate this class, and should not do so.

A note on the "World Start" date (called realStart in my script, and WorldStart by the RunUO devs):
I have noticed quite a bit of variance on when this should be. The RunUO Devs have this as 9/1/1997, which is the default that this script uses. However, I've found 2 other possible dates for this. GameFaqs (gamefaqs.com) reports that UO was released on 9/30/1997, which is reasonable. On the other hand, Stratics (uo.stratics.com) reports that right now (6/28/2006, 6:05 PM CDT), the date in Britannia is Oct. 72, 357. If my calculations are correct, this puts stratics' version of the UO Start Date on approx. 10/1/1992 :eek: Who's right? I have no idea, so I just went with the RunUO devs. The other dates are still in there, just commented out. This also means that my calculations may be off. If they are, please let me know.


Revision History:
July 7, 2006 - Version 1.1:
  • Fixed a bug in the way the month is calculated.
  • Added the ability to get a UOTimeStamp from a DateTime object (UOTimeStamp(DateTime time)).
  • Added the ability to get the length of time between 2 UOTimeStamps or from a particular UOTimeStamp until the current time.
June 28, 2006 - Version 1.0:
  • Initial Release.

TODO:
  • Add the ability to change the seasons in UO based on the current in-game Month.

This is my first real contribution to the RunUO community in the 4 years I've been a member. It is also only the second script I've released for RunUO, and the only one I consider to be reasonably complete. Enjoy. :)

--Arek
 

Attachments

  • UODateTime-1.1.zip
    12.5 KB · Views: 143

Shadow82

Sorceror
Looks good, but perhaps for future project it will go by the month's and change the map to the different conditions, as in winter months become snowy and such
 

Arek

Sorceror
Version 1.1 uploaded.

Changes since 1.0:
  • Fixed a bug in the way the month is calculated.
  • Added the ability to get a UOTimeStamp (fancy name for the seconds since midnight, world start) from a DateTime object (UOTimeStamp(DateTime time)). Useful for when items needing a UO date may already have a DateTime attached to them.
  • Added the ability to get the length of time between 2 UOTimeStamps or from a particular UOTimeStamp until the current time.

--Arek
 
Top