Description
A class containing functions for getting and manipulating dates and times.
This DateTime class allows you to create and manipulate dates and times that
are stored as FlexSim time. FlexSim time is defined as the number of seconds since
January 1st, 1601. The specified Model Time Units does not affect FlexSim time. It is always
in seconds.
Model Settings
When you start a new model, you can specify the start date and time of the model. That can
later be changed through the
Model Settings
page. On that page you can also specify the date and time display format. These formats can be used
when displaying a DateTime as a string or for creating a DateTime.
Excel Import/Export
When you import dates and times from an Excel document, you can do so as either strings
or as numbers which are in Excel time. This DateTime class can be used to convert those
strings or Excel time into FlexSim time. For exporting, you can write formatted dates and/or
times to a global table using the DateTime.toString
method.
Dashboard Charts
Dashboard charts like the Time Plot can use FlexSim time to display the dates and times
along the X or Y axis. This can be done by recording DateTimes in a Statistics Collector.
Properties
day |
The day of the month |
dayOfWeek |
The day of the week |
hour |
The hour of the day |
millisecond |
The millisecond of the second. |
minute |
The minute of the hour. |
month |
The month of the year |
second |
The second of the minute. |
totalDays |
The number of days since January 1st, 1601. |
totalHours |
The number of hours since January 1st, 1601. |
totalMilliseconds |
The number of milliseconds since January 1st, 1601. |
totalMinutes |
The number of minutes since January 1st, 1601. |
totalSeconds |
The number of seconds since January 1st, 1601. |
value |
The value of the date and time in FlexSim time. |
year |
The year |
Methods
toString |
Converts the DateTime into a human readable string. |
Constructor
Static Methods
days |
Constructs a new DateTime from the number of days. |
fromExcelTime |
Converts Excel time into FlexSim time. |
hours |
Constructs a new DateTime from the number of hours. |
milliseconds |
Constructs a new DateTime from the number of milliseconds. |
minutes |
Constructs a new DateTime from the number of minutes. |
seconds |
Constructs a new DateTime from the number of seconds. |
Operators
- |
Substracts one DateTime from another. |
!= |
Compares two DateTimes. |
+ |
Adds two DateTimes together. |
< |
Compares two DateTimes. |
<= |
Compares two DateTimes. |
== |
Compares two DateTimes. |
> |
Compares two DateTimes. |
>= |
Compares two DateTimes. |
Details
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double day
Description
The day of the month
Value ranges from 1 to 31.
double currentDay = Model.dateTime.day;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double dayOfWeek
Description
The day of the week
Value ranges from 1 to 7 with 1 being Sunday.
double currentDayOfWeek = Model.dateTime.dayOfWeek;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double hour
Description
The hour of the day
Value ranges from 0 to 23 with the 0 hour being from 12:00:00AM to 12:59:59AM.
double currentHour = Model.dateTime.hour;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double millisecond
Description
The millisecond of the second.
Value ranges from 0 to 999.
double currentMillisecond = Model.dateTime.millisecond;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double minute
Description
The minute of the hour.
Value ranges from 0 to 59.
double currentMinute = Model.dateTime.minute;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double month
Description
The month of the year
Value ranges from 1 to 12.
double currentMonth = Model.dateTime.month;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double second
Description
The second of the minute.
Value ranges from 0 to 59.
double currentSecond = Model.dateTime.second;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double totalDays
Description
The number of days since January 1st, 1601.
This will return a floating point number where the fraction represents the time into the current day.
double totalDays = Model.dateTime.totalDays;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double totalHours
Description
The number of hours since January 1st, 1601.
This will return a floating point number where the fraction represents the time into the current hour.
double totalHours = Model.dateTime.totalHours;
Do no remove, this fixes the anchor on doc.flexsim.com
DateTime.totalMilliseconds
readonly double totalMilliseconds
Description
The number of milliseconds since January 1st, 1601.
This will return a floating point number where the fraction represents the time into the current millisecond.
double totalMilliseconds = Model.dateTime.totalMilliseconds;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double totalMinutes
Description
The number of minutes since January 1st, 1601.
This will return a floating point number where the fraction represents the time into the current minute.
double totalMinutes = Model.dateTime.totalMinutes;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double totalSeconds
Description
The number of seconds since January 1st, 1601.
This is equivalent to DateTime.value or putting the DateTime into a double.
double totalSeconds = Model.dateTime.totalSeconds;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double value
Description
The value of the date and time in FlexSim time.
This property is equivalent to DateTime.
totalSeconds or putting a DateTime into a double.
double currentTime = Model.dateTime.value;
double currentTime = Model.dateTime;
Do no remove, this fixes the anchor on doc.flexsim.com
readonly double year
Description
The year
double currentYear = Model.dateTime.year;
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
format |
If format is NULL, the default windows date/time format will be used. |
Description
Converts the DateTime into a human readable string.
This method uses the windows settings for formatting. When using a custom format, the
following formatting options are available:
Specifier | Explanation | Example |
---|
%% | A % character | % |
%n | New line character | |
%t | Horizontal tab character | |
Year | | |
---|
%Y | The four digit year | 2017 |
%y | The last two digits of the year | 17 |
%C | The first two digits of the year | 20 |
Month | | |
---|
%b | The abbreviated month name | Oct |
%B | The full month name | October |
%m | The month as a number (1 - 12) | 10 |
Week | | |
---|
%U | The week of the year as a number with Sunday being the first day of the week (00 - 53) | 15 |
%W | The week of the year as a number with Monday being the first day of the week (00 - 53) | 15 |
Days of the year/month | | |
---|
%j | The day of the year as a three digit number (001 - 366) | 045 |
%d | The day of the month as a two digit number (01 - 31) | 05 |
%e | The day of the month as a single digit number (1 - 31) | 5 |
Day of the week | | |
---|
%a | The abbreviated weekday name | Fri |
%A | The full weekday name | Friday |
%w | The weekday as a number where Sunday is 0 (0 - 6) | 3 |
Hour, minute, second | | |
---|
%H | The hour as a two digit number, 24 hour clock (00 - 23) | 08 |
%I | The hour as a two digit number, 12 hour clock (01 - 12) | 08 |
%M | The minute as a two digit number (00 - 59) | 30 |
%S | The second as a two digit number (00 - 60) | 25 |
Other | | |
---|
%c | The standard date and time (windows default setting) | 09/24/17 08:00:00 |
%x | The standard date (windows default setting) | 09/24/17 |
%X | The standard time (windows default setting) | 08:00:00 |
%D | Equivalent to %m/%d/%y | 09/24/17 |
%F | Equivalent to %Y-%m-%d | 2017-09-24 |
%r | The 12-hour clock time (based on windows setting) | 08:00:00 |
%R | Equivalent to %H:%M | 08:00 |
%T | Equivalent to %H:%M:%S | 08:00:00 |
%p | AM or PM (based on windows setting) | AM |
%z | The offset from UTC time | -0600 |
%Z | The time zone name or abbreviation | Mountain Daylight Time |
string currentDateTime = Model.dateTime.toString();
string currentDateTime = Model.dateTime.toString("%H:%M:%S");
Do no remove, this fixes the anchor on doc.flexsim.com
DateTime(
double time
)
|
DateTime(
int days
,
int hours
,
int minutes = 0
,
int seconds = 0
)
|
Parameters
time |
The number of seconds since January 1st, 1601. |
days |
The number of days to add to the final DateTime |
hours |
The number of hours (usually less than 24) to add to the final DateTime |
minutes |
The number of minutes (usually less than 60) to add to the final DateTime |
seconds |
The number of seconds (usually less than 60) to add to the final DateTime |
Description
Constructs a DateTime.
The time can be treated as a duration if you add two DateTimes together. For example,
DateTime futureDate = Model.dateTime + DateTime(340); //Add 340 seconds to the current model time
DateTime theDate = DateTime(3600);
The second constructor can be used to create a DateTime that is rounded down to the nearset
important marker. For example, if the current model time is between 8:00 and 9:00 on a particular day, you could use
the following code to create a date time that represents 8:00 on that same day:
DateTime roundedToHour = DateTime(Model.dateTime.totalDays, Model.dateTime.hours);
Do no remove, this fixes the anchor on doc.flexsim.com
Description
Constructs a new DateTime from the number of days.
DateTime oneDay = DateTime.days(1);
Do no remove, this fixes the anchor on doc.flexsim.com
Description
Converts Excel time into FlexSim time.
When performing an
Excel Import,
the Data Distinction can be set to
Values Only. This will cause cells that store dates to be
imported into FlexSim as numbers that are in Excel time. This method will convert that Excel time
into FlexSim time.
DateTime dateTime = DateTime.fromExcelTime(excelTime);
Do no remove, this fixes the anchor on doc.flexsim.com
Description
Constructs a new DateTime from the number of hours.
DateTime oneHour = DateTime.hours(1);
Do no remove, this fixes the anchor on doc.flexsim.com
Description
Constructs a new DateTime from the number of milliseconds.
DateTime oneMillisecond = DateTime.milliseconds(1);
Do no remove, this fixes the anchor on doc.flexsim.com
Description
Constructs a new DateTime from the number of minutes.
DateTime oneMinute = DateTime.minutes(1);
Do no remove, this fixes the anchor on doc.flexsim.com
Description
Constructs a new DateTime from the number of seconds.
DateTime oneSecond = DateTime.seconds(1);
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to subtract from this DateTime. |
Returns
Description
Substracts one DateTime from another.
DateTime subTwoDates = Model.dateTime - dateTime;
DateTime subOneDay = Model.dateTime - DateTime.days(1);
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to compare to this DateTime. |
Returns
int
|
True if the two DateTimes are different, false otherwise. |
Description
Compares two DateTimes.
int differentDates = dateTime != Model.dateTime;
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to add this one to. |
Returns
Description
Adds two DateTimes together.
DateTime addTwoDates = Model.dateTime + dateTime;
DateTime addOneDay = Model.dateTime + DateTime.days(1);
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to compare to this DateTime. |
Returns
int
|
True if this DateTime is less than other, false otherwise. |
Description
Compares two DateTimes.
int pastDate = dateTime < Model.dateTime;
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to compare to this DateTime. |
Returns
int
|
True if this DateTime is less than or equal to other, false otherwise. |
Description
Compares two DateTimes.
int pastDate = dateTime <= Model.dateTime;
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to compare to this DateTime. |
Returns
int
|
True if the two DateTimes are exactly the same, false otherwise. |
Description
Compares two DateTimes.
int sameDate = dateTime == Model.dateTime;
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to compare to this DateTime. |
Returns
int
|
True if this DateTime is greater than other, false otherwise. |
Description
Compares two DateTimes.
int futureDate = dateTime > Model.dateTime;
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
other |
The DateTime to compare to this DateTime. |
Returns
int
|
True if this DateTime is greater than or equal to other, false otherwise. |
Description
Compares two DateTimes.
int futureDate = dateTime >= Model.dateTime;