1
0
Fork 0
cl-sites/guile.html_node/SRFI_002d19-String-to-date.html
2024-12-17 12:49:28 +01:00

117 lines
7.1 KiB
HTML

<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual documents Guile version 3.0.10.
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
Inc.
Copyright (C) 2021 Maxime Devos
Copyright (C) 2024 Tomas Volf
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled "GNU Free
Documentation License." -->
<title>SRFI-19 String to date (Guile Reference Manual)</title>
<meta name="description" content="SRFI-19 String to date (Guile Reference Manual)">
<meta name="keywords" content="SRFI-19 String to date (Guile Reference Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content=".texi2any-real">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="SRFI_002d19.html" rel="up" title="SRFI-19">
<link href="SRFI_002d19-Date-to-string.html" rel="prev" title="SRFI-19 Date to string">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
</head>
<body lang="en">
<div class="subsubsection-level-extent" id="SRFI_002d19-String-to-date">
<div class="nav-panel">
<p>
Previous: <a href="SRFI_002d19-Date-to-string.html" accesskey="p" rel="prev">SRFI-19 Date to string</a>, Up: <a href="SRFI_002d19.html" accesskey="u" rel="up">SRFI-19 - Time/Date Library</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsubsection" id="SRFI_002d19-String-to-date-1"><span>7.5.16.6 SRFI-19 String to date<a class="copiable-link" href="#SRFI_002d19-String-to-date-1"> &para;</a></span></h4>
<a class="index-entry-id" id="index-string-to-date"></a>
<a class="index-entry-id" id="index-date_002c-from-string"></a>
<dl class="first-deffn first-defun-alias-first-deffn">
<dt class="deffn defun-alias-deffn" id="index-string_002d_003edate"><span class="category-def">Function: </span><span><strong class="def-name">string-&gt;date</strong> <var class="def-var-arguments">input template</var><a class="copiable-link" href="#index-string_002d_003edate"> &para;</a></span></dt>
<dd><p>Convert an <var class="var">input</var> string to a date under the control of a
<var class="var">template</var> string. Return a newly created date object.
</p>
<p>Literal characters in <var class="var">template</var> must match characters in
<var class="var">input</var> and &lsquo;<samp class="samp">~</samp>&rsquo; escapes must match the input forms described
in the table below. &ldquo;Skip to&rdquo; means characters up to one of the
given type are ignored, or &ldquo;no skip&rdquo; for no skipping. &ldquo;Read&rdquo; is
what&rsquo;s then read, and &ldquo;Set&rdquo; is the field affected in the date
object.
</p>
<p>For example &lsquo;<samp class="samp">~Y</samp>&rsquo; skips input characters until a digit is reached,
at which point it expects a year and stores that to the year field of
the date.
</p>
<table class="multitable">
<tbody><tr><td></td><td>Skip to</td><td>Read</td><td>Set</td></tr>
<tr><td><code class="code">~~</code></td><td>no skip</td><td>literal ~</td><td>nothing</td></tr>
<tr><td><code class="code">~a</code></td><td><code class="code">char-alphabetic?</code></td><td>locale abbreviated weekday name</td><td>nothing</td></tr>
<tr><td><code class="code">~A</code></td><td><code class="code">char-alphabetic?</code></td><td>locale full weekday name</td><td>nothing</td></tr>
<tr><td><code class="code">~b</code></td><td><code class="code">char-alphabetic?</code></td><td>locale abbreviated month name</td><td><code class="code">date-month</code></td></tr>
<tr><td><code class="code">~B</code></td><td><code class="code">char-alphabetic?</code></td><td>locale full month name</td><td><code class="code">date-month</code></td></tr>
<tr><td><code class="code">~d</code></td><td><code class="code">char-numeric?</code></td><td>day of month</td><td><code class="code">date-day</code></td></tr>
<tr><td><code class="code">~e</code></td><td>no skip</td><td>day of month, blank padded</td><td><code class="code">date-day</code></td></tr>
<tr><td><code class="code">~h</code></td><td>same as &lsquo;<samp class="samp">~b</samp>&rsquo;</td></tr>
<tr><td><code class="code">~H</code></td><td><code class="code">char-numeric?</code></td><td>hour</td><td><code class="code">date-hour</code></td></tr>
<tr><td><code class="code">~k</code></td><td>no skip</td><td>hour, blank padded</td><td><code class="code">date-hour</code></td></tr>
<tr><td><code class="code">~m</code></td><td><code class="code">char-numeric?</code></td><td>month</td><td><code class="code">date-month</code></td></tr>
<tr><td><code class="code">~M</code></td><td><code class="code">char-numeric?</code></td><td>minute</td><td><code class="code">date-minute</code></td></tr>
<tr><td><code class="code">~N</code></td><td><code class="code">char-numeric?</code></td><td>nanosecond</td><td><code class="code">date-nanosecond</code></td></tr>
<tr><td><code class="code">~S</code></td><td><code class="code">char-numeric?</code></td><td>second</td><td><code class="code">date-second</code></td></tr>
<tr><td><code class="code">~y</code></td><td>no skip</td><td>2-digit year</td><td><code class="code">date-year</code> within 50 years</td></tr>
<tr><td><code class="code">~Y</code></td><td><code class="code">char-numeric?</code></td><td>year</td><td><code class="code">date-year</code></td></tr>
<tr><td><code class="code">~z</code></td><td>no skip</td><td>time zone</td><td>date-zone-offset</td></tr>
</tbody>
</table>
<p>Notice that the weekday matching forms don&rsquo;t affect the date object
returned, instead the weekday will be derived from the day, month and
year.
</p>
<p>Conversion is locale-dependent on systems that support it
(see <a class="pxref" href="Accessing-Locale-Information.html">Accessing Locale Information</a>). See <a class="xref" href="Locales.html"><code class="code">setlocale</code></a>, for information on how to change the current
locale.
</p></dd></dl>
</div>
<hr>
<div class="nav-panel">
<p>
Previous: <a href="SRFI_002d19-Date-to-string.html">SRFI-19 Date to string</a>, Up: <a href="SRFI_002d19.html">SRFI-19 - Time/Date Library</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>