These functions should be placed in BaseCamp/Calendar
implementation.dm
LoadCalendarFromXml(filename)
world << "start [filename]"
// This loads the calendar properties from an html file allowing
// you to edit the initial settings of the calendar.
var/XML/Element/root = xmlRootFromFile(filename)
_startingTimeOffset = text2num(root.FirstChildText("startingTimeOffset"))
_baseYear = text2num(root.FirstChildText("baseYear"))
_timeZone = text2num(root.FirstChildText("timeZone"))
_alwaysConsiderLeapYears = text2num(root.FirstChildText("alwaysConsiderLeapYears"))
_timeFormat = root.FirstChildText("timeFormat")
_isCustomCalendar = text2num(root.FirstChildText("isCustomCalendar"))
_timeSpeed = text2num(root.FirstChildText("timeSpeed"))
_hoursPerDay = text2num(root.FirstChildText("hoursPerDay"))
for (var/XML/Element/e in root.Descendants("dayNames"))
for (var/XML/Element/d in e.ChildElements())
if (!_dayNames)
_dayNames = new/list()
_dayNames += d.Text()
for (var/XML/Element/e in root.Descendants("monthNames"))
for (var/XML/Element/m in e.ChildElements())
if (!_monthNames)
_monthNames = new/list()
_monthNames += m.Text()
for (var/XML/Element/e in root.Descendants("numDaysInMonths"))
for (var/XML/Element/m in e.ChildElements())
if (!_numDaysInMonths)
_numDaysInMonths = new/list()
_numDaysInMonths += text2num(m.Text())
for (var/XML/Element/e in root.Descendants("numDaysInLeapMonths"))
for (var/XML/Element/m in e.ChildElements())
if (!_numDaysInLeapMonths)
_numDaysInLeapMonths = new/list()
_numDaysInLeapMonths += text2num(m.Text())
return ..()
Calendar.dm
//////////////////////
// Loading Calendar //
//////////////////////
LoadCalendarFromXml(filename)
/* This loads the calendar properties from an html file allowing
you to edit the initial settings of the calendar.
XML example.
<calendar>
<startingTimeOffset>0</startingTimeOffset>
<baseYear>2000</baseYear>
<timeZone>0</timeZone>
<alwaysConsiderLeapYears>0</alwaysConsiderLeapYears>
<timeFormat>%D %M %d, %y %H:%i %s %p</timeFormat>
<isCustomCalendar>0</isCustomCalendar>
<timeSpeed>1</timeSpeed>
<hoursPerDay>24</hoursPerDay>
<dayNames>
<day>Sunday</day>
<day>Monday</day>
<day>Tuesday</day>
<day>Wedndesday</day>
<day>Thursday</day>
<day>Friday</day>
<day>Saturday</day>
</dayNames>
<monthNames>
<month>January</month>
<month>February</month>
<month>March</month>
<month>April</month>
<month>May</month>
<month>June</month>
<month>July</month>
<month>August</month>
<month>September</month>
<month>October</month>
<month>November</month>
<month>December</month>
</monthNames>
<numDaysInMonths>
<month>31</month>
<month>28</month>
<month>31</month>
<month>30</month>
<month>31</month>
<month>30</month>
<month>31</month>
<month>31</month>
<month>30</month>
<month>31</month>
<month>30</month>
<month>31</month>
</numDaysInMonths>
<numDaysInLeapMonths>
<month>31</month>
<month>29</month>
<month>31</month>
<month>30</month>
<month>31</month>
<month>30</month>
<month>31</month>
<month>31</month>
<month>30</month>
<month>31</month>
<month>30</month>
<month>31</month>
</numDaysInLeapMonths>
</calendar>
Code example.
var/BaseCamp/Calendar/my_calendar = new()
my_calendar.LoadCalendarFromXml("calendar.xml")
var/now = my_calendar.CurrentTime()
src << "The current date and time for this world is: [now]"
*/
return ..()