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 September 16, 2026
Example 2
Example2
=
Paragraph
{
var
start
=
#2020-01-01#
;
"There are "
; (
now
-
start
)
.
Day;
" days between "
;
start
;
" and now."
;
};
There are 2450 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
9/16/2026 8:39:00 AM
d
9/16/2026
D
Wednesday, September 16, 2026
f
Wednesday, September 16, 2026 8:39 AM
F
Wednesday, September 16, 2026 8:39:00 AM
g
9/16/2026 8:39 AM
m
September 16
r
Wed, 16 Sep 2026 08:39:00 GMT
s
2026-09-16T08:39:00
t
8:39 AM
T
8:39:00 AM
u
2026-09-16 08:39:00Z
U
Wednesday, September 16, 2026 3:39:00 PM
Y
September 2026
o
2026-09-16T08:39:00.0035105
yyyy-MM-ddTHH:mm:ss.fffffffzzz
2026-09-16T08:39:00.0035105-07:00
yyyy-MM-ddTHH:mm:sszzz
2026-09-16T08:39:00-07:00
MM/yyyy
09/2026
MM/dd/yyyy HH:mm
09/16/2026 08:39
yyyyMMdd
20260916