33 lines
No EOL
2.1 KiB
HTML
33 lines
No EOL
2.1 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>DateTime.format — Ludic</title>
|
||
<meta name="description" content="Render an instant as text using a token pattern.">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-datetime.html">DateTime</a> <span>›</span> <span class="here">DateTime.format</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-method">method</span>
|
||
<h1 id="top">DateTime.format</h1>
|
||
</div>
|
||
<code class="sig">DateTime.format(dt, pattern) -> string</code>
|
||
<div class="desc"><p>Renders the instant <code>dt</code> as a string, filling the tokens in <code>pattern</code> with zero-padded fields and copying every other character through verbatim. The pattern <b>must be a string literal</b> — it is expanded at compile time, so there is no runtime pattern scanner. Recognised tokens: <code>YYYY</code> (4-digit year), <code>YY</code> (2-digit year), <code>MM</code> (month), <code>DD</code> (day), <code>HH</code> (hour, 24h), <code>mm</code> (minute), <code>ss</code> (second).</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||
handler Step phase Update {
|
||
let t = DateTime.from(2026, 8, 30, 7, 5, 9)
|
||
let stamp = DateTime.format(t, "YYYY-MM-DD HH:mm:ss") # "2026-08-30 07:05:09"
|
||
}
|
||
}</pre></div>
|
||
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |