# packages/core/src/features/viz/lib/utc-labels.ts
This is the source snapshot used to build these API details. [View this revision on GitHub](https://github.com/benlesh/pibbl/blob/272a94aaf62e0bd6ad8726a4c607a76a9ec44ca1/packages/core/src/features/viz/lib/utc-labels.ts#L12).

[Back to reference](/reference/functions/utc-domains/)

<pre class="api-source"><code><span id="L1"><a href="#L1" aria-label="Line 1">1</a> /** Locale used for compact UTC tick text. See {@link utcTickLabels}. */</span>
<span id="L2"><a href="#L2" aria-label="Line 2">2</a> export interface UTCTickLabelOptions {</span>
<span id="L3"><a href="#L3" aria-label="Line 3">3</a>   /** BCP 47 locale, default en-US. Calendar is always Gregorian; time zone is UTC. */</span>
<span id="L4"><a href="#L4" aria-label="Line 4">4</a>   readonly locale?: string;</span>
<span id="L5"><a href="#L5" aria-label="Line 5">5</a> }</span>
<span id="L6"><a href="#L6" aria-label="Line 6">6</a> /**</span>
<span id="L7"><a href="#L7" aria-label="Line 7">7</a>  * Creates compact labels with calendar context retained on every tick.</span>
<span id="L8"><a href="#L8" aria-label="Line 8">8</a>  * @param values - At most 100 safe integer epoch milliseconds within Date range, in any order.</span>
<span id="L9"><a href="#L9" aria-label="Line 9">9</a>  * @param options - Explicit locale; default en-US.</span>
<span id="L10"><a href="#L10" aria-label="Line 10">10</a>  * @returns Frozen labels in input order. No geometry or scale state changes. See {@link UTCTickLabelOptions}.</span>
<span id="L11"><a href="#L11" aria-label="Line 11">11</a>  */</span>
<span id="L12"><a href="#L12" aria-label="Line 12">12</a> export function utcTickLabels(values: readonly number[], options: UTCTickLabelOptions = {}): readonly string[] {</span>
<span id="L13"><a href="#L13" aria-label="Line 13">13</a>   if (!Array.isArray(values) || values.length &gt; 100 || values.some(v =&gt; !Number.isSafeInteger(v) || Math.abs(v) &gt; 8_640_000_000_000_000))</span>
<span id="L14"><a href="#L14" aria-label="Line 14">14</a>     throw new RangeError(&quot;utcTickLabels requires at most 100 integer timestamps within Date range.&quot;);</span>
<span id="L15"><a href="#L15" aria-label="Line 15">15</a>   const dates = values.map(value =&gt; new Date(value));</span>
<span id="L16"><a href="#L16" aria-label="Line 16">16</a>   const midnight = (date: Date) =&gt; date.getUTCHours() === 0 &amp;&amp; date.getUTCMinutes() === 0 &amp;&amp; date.getUTCSeconds() === 0 &amp;&amp; date.getUTCMilliseconds() === 0;</span>
<span id="L17"><a href="#L17" aria-label="Line 17">17</a>   const months = dates.every(date =&gt; midnight(date) &amp;&amp; date.getUTCDate() === 1);</span>
<span id="L18"><a href="#L18" aria-label="Line 18">18</a>   const years = months &amp;&amp; dates.every(date =&gt; date.getUTCMonth() === 0);</span>
<span id="L19"><a href="#L19" aria-label="Line 19">19</a>   const days = dates.every(midnight);</span>
<span id="L20"><a href="#L20" aria-label="Line 20">20</a>   const milliseconds = dates.some(date =&gt; date.getUTCMilliseconds() !== 0);</span>
<span id="L21"><a href="#L21" aria-label="Line 21">21</a>   const seconds = milliseconds || dates.some(date =&gt; date.getUTCSeconds() !== 0);</span>
<span id="L22"><a href="#L22" aria-label="Line 22">22</a>   const formatter = new Intl.DateTimeFormat(options.locale ?? &quot;en-US&quot;, {</span>
<span id="L23"><a href="#L23" aria-label="Line 23">23</a>     timeZone: &quot;UTC&quot;, calendar: &quot;gregory&quot;, year: &quot;numeric&quot;,</span>
<span id="L24"><a href="#L24" aria-label="Line 24">24</a>     ...(years ? {} : { month: &quot;short&quot; as const }),</span>
<span id="L25"><a href="#L25" aria-label="Line 25">25</a>     ...(months ? {} : { day: &quot;numeric&quot; as const }),</span>
<span id="L26"><a href="#L26" aria-label="Line 26">26</a>     ...(days ? {} : { hour: &quot;2-digit&quot; as const, minute: &quot;2-digit&quot; as const, hourCycle: &quot;h23&quot; as const }),</span>
<span id="L27"><a href="#L27" aria-label="Line 27">27</a>     ...(seconds ? { second: &quot;2-digit&quot; as const } : {}),</span>
<span id="L28"><a href="#L28" aria-label="Line 28">28</a>     ...(milliseconds ? { fractionalSecondDigits: 3 as const } : {}),</span>
<span id="L29"><a href="#L29" aria-label="Line 29">29</a>     ...(dates.some(date =&gt; date.getUTCFullYear() &lt;= 0) ? { era: &quot;short&quot; as const } : {}),</span>
<span id="L30"><a href="#L30" aria-label="Line 30">30</a>   });</span>
<span id="L31"><a href="#L31" aria-label="Line 31">31</a>   return Object.freeze(dates.map(date =&gt; formatter.format(date)));</span>
<span id="L32"><a href="#L32" aria-label="Line 32">32</a> }</span>
<span id="L33"><a href="#L33" aria-label="Line 33">33</a> </span></code></pre>

## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
