sealed
class
DateTime
A date and time to 0.001 seconds.
public
DateTime
.Constructor(
int
year
,
int
month
=
null
,
int
day
=
null
,
int
hour
=
null
,
int
minute
=
null
,
double
second
=
null
)
public
DatePrecisions
DateTime
.Precision
The amount of precision in the date
public
double
DateTime
.Second
Returns the seconds as a real number
public
int
DateTime
.Ticks
Returns the number of 100 nanoseconds in the time
public
DateTime
DateTime
.WithPrecision(
DatePrecisions
precision
)
A new object at the specified precision
public
int
DateTime
.Year
Returns the year
public
int
DateTime
.Month
Returns the month
public
int
DateTime
.Day
Returns the day
public
int
DateTime
.Hour
Returns the hour
public
int
DateTime
.Minute
Returns the minute
public
int
DateTime
.DayOfWeek
The day of the week (0 == Sunday)
public
int
DateTime
.DayOfYear
The day of the year
public
static
DateTime
DateTime
.Now(
DatePrecisions
precision
=
null
)
The current time
public
static
DateTime
DateTime
.Parse8601(
text
)
Convert an ISO8601 formatted string to a datetime
public
static
DateTime
DateTime
.FromUnix(
value
)
Convert a unix tick count to a datetime
public
static
DatePart
PartYear(
value
)
public
static
DatePart
PartMonth(
value
)
public
static
DatePart
PartDay(
value
)
public
static
DatePart
PartHour(
value
)
public
static
DatePart
PartMinute(
value
)
public
static
DatePart
PartSecond(
value
)
public
static
DatePart
PartDayOfWeek(
value
)
public
static
DatePart
PartDayOfYear(
value
)
public
virtual
object
.GetLayoutTip
Return a layout for the hint popup
public
virtual
object
.GetLayoutSpan
Return a layout inside a span
public
virtual
object
.GetLayoutBlock
Return a layout inside a block
public
virtual
object
.GetSourceReference
Return a source reference for this object
public
virtual
void
object
.GetTexSource(
source
)
LaTeX source code for this object
public
virtual
Icon
object
.GetIcon
Return a icon for this object
public
virtual
int
object
.Compare(
value
)
Compares this object with another and returns (-1, 0, or 1)
Example 1
Example
=
Paragraph
{
"The current date is "
;
TextFormat
:
"MMMM d, yyyy"
;
now
;
};
The current date is August 3, 2026
Example 2
Example2
=
Paragraph
{
var
start
=
#2020-01-01#
;
"There are "
; (
now
-
start
)
.
Day;
" days between "
;
start
;
" and now."
;
};
There are 2406 days between 2020-01-01 and now.
Example 3
Example3
=
Block
{
var
now
=
DateTime
.
Now
;
var
formats
=
[
// General formatters
"G"
,
"d"
,
"D"
,
"f"
,
"F"
,
"g"
,
"m"
,
"r"
,
"s"
,
"t"
,
"T"
,
"u"
,
"U"
,
"Y"
,
"o"
,
// Compound formats
"yyyy-MM-ddTHH:mm:ss.fffffffzzz"
,
"yyyy-MM-ddTHH:mm:sszzz"
,
"MM/yyyy"
,
"MM/dd/yyyy HH:mm"
,
// Notice the escaped \\
"yyyyMMdd"
,
];
NytrilStyle
.
Heading3
{
"Format Examples"
;
};
Table
(0.5,
PadLR
(3), [
Column
.
Fit
(2"), 3"]) {
Row
{
Background
:
NytrilPalette
.
TableTitleBack
;
TextColor
:
NytrilPalette
.
TableTitleFore
;
"Formatter"
;
"Output"
;
};
foreach
(
var
format
in
formats
) {
NytrilStyle
.
ListRow
(
each0
) {
format
;
Span
{
TextFormat
:
format
;
now
;
};
}
}
}
};
Format Examples
Formatter
Output
G
8/3/2026 6:05:02 PM
d
8/3/2026
D
Monday, August 3, 2026
f
Monday, August 3, 2026 6:05 PM
F
Monday, August 3, 2026 6:05:02 PM
g
8/3/2026 6:05 PM
m
August 3
r
Mon, 03 Aug 2026 18:05:02 GMT
s
2026-08-03T18:05:02
t
6:05 PM
T
6:05:02 PM
u
2026-08-03 18:05:02Z
U
Tuesday, August 4, 2026 1:05:02 AM
Y
August 2026
o
2026-08-03T18:05:02.5992807
yyyy-MM-ddTHH:mm:ss.fffffffzzz
2026-08-03T18:05:02.5992807-07:00
yyyy-MM-ddTHH:mm:sszzz
2026-08-03T18:05:02-07:00
MM/yyyy
08/2026
MM/dd/yyyy HH:mm
08/03/2026 18:05
yyyyMMdd
20260803