⏱️Meridiem Time

What is Meridiem Time

Meridiem Time is the time method of choice for COZY: Weather. At its core, Meridiem Time transforms your world time to a variety of other structures and data types so that it can be easily refenced by any number of systems.

Meridiem Time is a struct that contains an int field for hours (0-23) and minutes (0-59). These values are parsed and saved as a float value (0-1) which can be manipulated on the backend or reconverted back into Meridiem Time for easy viewing on the frontend.

Using Meridiem Time

Meridiem Time is a completely original structure for time management, but it is incredibly simple to use in a variety of cases.

Get the Current Time

Using the Time Module, you can easily get the current time and reference it in your game. This code block will grab the current time from the Time Module:

using DistantLands.Cozy

//Cache the reference to CozyWeather.instance as weatherSphere
//Get the current hour (24 hour scale)
weatherSphere.timeModule.currentTime.hours;
//Get the current minute (60 minute scale)
weatherSphere.timeModule.currentTime.minutes;

Convert from Meridiem Time to Float

//Convert to float
float dayPercentage = (float)weatherSphere.timeModule.currentTime;
//And back to Meridiem Time
float currentTime = (MeridiemTime)dayPercentage;

Add Six Hours to a Time

//Meridiem Time can be added, subtracted, and verified without transforming its data type.
MeridiemTime newTime = oldTime + new MeridiemTime(6, 0);

Convert to a DateTime struct

DateTime newTime = (DateTime)oldTime

Last updated