205 lines
16 KiB
HTML
205 lines
16 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 Time (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="SRFI-19 Time (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="SRFI-19 Time (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.html" rel="next" title="SRFI-19 Date">
|
||
|
<link href="SRFI_002d19-Introduction.html" rel="prev" title="SRFI-19 Introduction">
|
||
|
<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-Time">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="SRFI_002d19-Date.html" accesskey="n" rel="next">SRFI-19 Date</a>, Previous: <a href="SRFI_002d19-Introduction.html" accesskey="p" rel="prev">SRFI-19 Introduction</a>, Up: <a href="SRFI_002d19.html" accesskey="u" rel="up">SRFI-19 - Time/Date Library</a> [<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-Time-1"><span>7.5.16.2 SRFI-19 Time<a class="copiable-link" href="#SRFI_002d19-Time-1"> ¶</a></span></h4>
|
||
|
<a class="index-entry-id" id="index-time-2"></a>
|
||
|
|
||
|
<p>A <em class="dfn">time</em> object has type, seconds and nanoseconds fields
|
||
|
representing a point in time starting from some epoch. This is an
|
||
|
arbitrary point in time, not just a time of day. Although times are
|
||
|
represented in nanoseconds, the actual resolution may be lower.
|
||
|
</p>
|
||
|
<p>The following variables hold the possible time types. For instance
|
||
|
<code class="code">(current-time time-process)</code> would give the current CPU process
|
||
|
time.
|
||
|
</p>
|
||
|
<dl class="first-defvr first-defvar-alias-first-defvr">
|
||
|
<dt class="defvr defvar-alias-defvr" id="index-time_002dutc"><span class="category-def">Variable: </span><span><strong class="def-name">time-utc</strong><a class="copiable-link" href="#index-time_002dutc"> ¶</a></span></dt>
|
||
|
<dd><p>Universal Coordinated Time (UTC).
|
||
|
<a class="index-entry-id" id="index-UTC-1"></a>
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-defvr first-defvar-alias-first-defvr">
|
||
|
<dt class="defvr defvar-alias-defvr" id="index-time_002dtai"><span class="category-def">Variable: </span><span><strong class="def-name">time-tai</strong><a class="copiable-link" href="#index-time_002dtai"> ¶</a></span></dt>
|
||
|
<dd><p>International Atomic Time (TAI).
|
||
|
<a class="index-entry-id" id="index-TAI-1"></a>
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-defvr first-defvar-alias-first-defvr">
|
||
|
<dt class="defvr defvar-alias-defvr" id="index-time_002dmonotonic"><span class="category-def">Variable: </span><span><strong class="def-name">time-monotonic</strong><a class="copiable-link" href="#index-time_002dmonotonic"> ¶</a></span></dt>
|
||
|
<dd><p>Monotonic time, meaning a monotonically increasing time starting from
|
||
|
an unspecified epoch.
|
||
|
</p>
|
||
|
<p>Note that in the current implementation <code class="code">time-monotonic</code> is the
|
||
|
same as <code class="code">time-tai</code>, and unfortunately is therefore affected by
|
||
|
adjustments to the system clock. Perhaps this will change in the
|
||
|
future.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-defvr first-defvar-alias-first-defvr">
|
||
|
<dt class="defvr defvar-alias-defvr" id="index-time_002dduration"><span class="category-def">Variable: </span><span><strong class="def-name">time-duration</strong><a class="copiable-link" href="#index-time_002dduration"> ¶</a></span></dt>
|
||
|
<dd><p>A duration, meaning simply a difference between two times.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-defvr first-defvar-alias-first-defvr">
|
||
|
<dt class="defvr defvar-alias-defvr" id="index-time_002dprocess"><span class="category-def">Variable: </span><span><strong class="def-name">time-process</strong><a class="copiable-link" href="#index-time_002dprocess"> ¶</a></span></dt>
|
||
|
<dd><p>CPU time spent in the current process, starting from when the process
|
||
|
began.
|
||
|
<a class="index-entry-id" id="index-process-time"></a>
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-defvr first-defvar-alias-first-defvr">
|
||
|
<dt class="defvr defvar-alias-defvr" id="index-time_002dthread"><span class="category-def">Variable: </span><span><strong class="def-name">time-thread</strong><a class="copiable-link" href="#index-time_002dthread"> ¶</a></span></dt>
|
||
|
<dd><p>CPU time spent in the current thread. Not currently implemented.
|
||
|
<a class="index-entry-id" id="index-thread-time"></a>
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<br>
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-time_003f-1"><span class="category-def">Function: </span><span><strong class="def-name">time?</strong> <var class="def-var-arguments">obj</var><a class="copiable-link" href="#index-time_003f-1"> ¶</a></span></dt>
|
||
|
<dd><p>Return <code class="code">#t</code> if <var class="var">obj</var> is a time object, or <code class="code">#f</code> if not.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-make_002dtime"><span class="category-def">Function: </span><span><strong class="def-name">make-time</strong> <var class="def-var-arguments">type nanoseconds seconds</var><a class="copiable-link" href="#index-make_002dtime"> ¶</a></span></dt>
|
||
|
<dd><p>Create a time object with the given <var class="var">type</var>, <var class="var">seconds</var> and
|
||
|
<var class="var">nanoseconds</var>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-time_002dtype"><span class="category-def">Function: </span><span><strong class="def-name">time-type</strong> <var class="def-var-arguments">time</var><a class="copiable-link" href="#index-time_002dtype"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-time_002dnanosecond"><span class="category-def">Function: </span><span><strong class="def-name">time-nanosecond</strong> <var class="def-var-arguments">time</var><a class="copiable-link" href="#index-time_002dnanosecond"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-time_002dsecond"><span class="category-def">Function: </span><span><strong class="def-name">time-second</strong> <var class="def-var-arguments">time</var><a class="copiable-link" href="#index-time_002dsecond"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-set_002dtime_002dtype_0021"><span class="category-def">Function: </span><span><strong class="def-name">set-time-type!</strong> <var class="def-var-arguments">time type</var><a class="copiable-link" href="#index-set_002dtime_002dtype_0021"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-set_002dtime_002dnanosecond_0021"><span class="category-def">Function: </span><span><strong class="def-name">set-time-nanosecond!</strong> <var class="def-var-arguments">time nsec</var><a class="copiable-link" href="#index-set_002dtime_002dnanosecond_0021"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-set_002dtime_002dsecond_0021"><span class="category-def">Function: </span><span><strong class="def-name">set-time-second!</strong> <var class="def-var-arguments">time sec</var><a class="copiable-link" href="#index-set_002dtime_002dsecond_0021"> ¶</a></span></dt>
|
||
|
<dd><p>Get or set the type, seconds or nanoseconds fields of a time object.
|
||
|
</p>
|
||
|
<p><code class="code">set-time-type!</code> merely changes the field, it doesn’t convert the
|
||
|
time value. For conversions, see <a class="ref" href="SRFI_002d19-Time_002fDate-conversions.html">SRFI-19 Time/Date conversions</a>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-copy_002dtime"><span class="category-def">Function: </span><span><strong class="def-name">copy-time</strong> <var class="def-var-arguments">time</var><a class="copiable-link" href="#index-copy_002dtime"> ¶</a></span></dt>
|
||
|
<dd><p>Return a new time object, which is a copy of the given <var class="var">time</var>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-current_002dtime-2"><span class="category-def">Function: </span><span><strong class="def-name">current-time</strong> <var class="def-var-arguments">[type]</var><a class="copiable-link" href="#index-current_002dtime-2"> ¶</a></span></dt>
|
||
|
<dd><p>Return the current time of the given <var class="var">type</var>. The default
|
||
|
<var class="var">type</var> is <code class="code">time-utc</code>.
|
||
|
</p>
|
||
|
<p>Note that the name <code class="code">current-time</code> conflicts with the Guile core
|
||
|
<code class="code">current-time</code> function (see <a class="pxref" href="Time.html">Time</a>) as well as the SRFI-18
|
||
|
<code class="code">current-time</code> function (see <a class="pxref" href="SRFI_002d18-Time.html">SRFI-18 Time</a>). Applications
|
||
|
wanting to use more than one of these functions will need to refer to
|
||
|
them by different names.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-time_002dresolution"><span class="category-def">Function: </span><span><strong class="def-name">time-resolution</strong> <var class="def-var-arguments">[type]</var><a class="copiable-link" href="#index-time_002dresolution"> ¶</a></span></dt>
|
||
|
<dd><p>Return the resolution, in nanoseconds, of the given time <var class="var">type</var>.
|
||
|
The default <var class="var">type</var> is <code class="code">time-utc</code>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-time_003c_003d_003f"><span class="category-def">Function: </span><span><strong class="def-name">time<=?</strong> <var class="def-var-arguments">t1 t2</var><a class="copiable-link" href="#index-time_003c_003d_003f"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-time_003c_003f"><span class="category-def">Function: </span><span><strong class="def-name">time<?</strong> <var class="def-var-arguments">t1 t2</var><a class="copiable-link" href="#index-time_003c_003f"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-time_003d_003f"><span class="category-def">Function: </span><span><strong class="def-name">time=?</strong> <var class="def-var-arguments">t1 t2</var><a class="copiable-link" href="#index-time_003d_003f"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-time_003e_003d_003f"><span class="category-def">Function: </span><span><strong class="def-name">time>=?</strong> <var class="def-var-arguments">t1 t2</var><a class="copiable-link" href="#index-time_003e_003d_003f"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-time_003e_003f"><span class="category-def">Function: </span><span><strong class="def-name">time>?</strong> <var class="def-var-arguments">t1 t2</var><a class="copiable-link" href="#index-time_003e_003f"> ¶</a></span></dt>
|
||
|
<dd><p>Return <code class="code">#t</code> or <code class="code">#f</code> according to the respective relation
|
||
|
between time objects <var class="var">t1</var> and <var class="var">t2</var>. <var class="var">t1</var> and <var class="var">t2</var>
|
||
|
must be the same time type.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-time_002ddifference"><span class="category-def">Function: </span><span><strong class="def-name">time-difference</strong> <var class="def-var-arguments">t1 t2</var><a class="copiable-link" href="#index-time_002ddifference"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-time_002ddifference_0021"><span class="category-def">Function: </span><span><strong class="def-name">time-difference!</strong> <var class="def-var-arguments">t1 t2</var><a class="copiable-link" href="#index-time_002ddifference_0021"> ¶</a></span></dt>
|
||
|
<dd><p>Return a time object of type <code class="code">time-duration</code> representing the
|
||
|
period between <var class="var">t1</var> and <var class="var">t2</var>. <var class="var">t1</var> and <var class="var">t2</var> must be
|
||
|
the same time type.
|
||
|
</p>
|
||
|
<p><code class="code">time-difference</code> returns a new time object,
|
||
|
<code class="code">time-difference!</code> may modify <var class="var">t1</var> to form its return.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
||
|
<dt class="deffn defun-alias-deffn" id="index-add_002dduration"><span class="category-def">Function: </span><span><strong class="def-name">add-duration</strong> <var class="def-var-arguments">time duration</var><a class="copiable-link" href="#index-add_002dduration"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-add_002dduration_0021"><span class="category-def">Function: </span><span><strong class="def-name">add-duration!</strong> <var class="def-var-arguments">time duration</var><a class="copiable-link" href="#index-add_002dduration_0021"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-subtract_002dduration"><span class="category-def">Function: </span><span><strong class="def-name">subtract-duration</strong> <var class="def-var-arguments">time duration</var><a class="copiable-link" href="#index-subtract_002dduration"> ¶</a></span></dt>
|
||
|
<dt class="deffnx defunx-alias-deffnx def-cmd-deffn" id="index-subtract_002dduration_0021"><span class="category-def">Function: </span><span><strong class="def-name">subtract-duration!</strong> <var class="def-var-arguments">time duration</var><a class="copiable-link" href="#index-subtract_002dduration_0021"> ¶</a></span></dt>
|
||
|
<dd><p>Return a time object which is <var class="var">time</var> with the given <var class="var">duration</var>
|
||
|
added or subtracted. <var class="var">duration</var> must be a time object of type
|
||
|
<code class="code">time-duration</code>.
|
||
|
</p>
|
||
|
<p><code class="code">add-duration</code> and <code class="code">subtract-duration</code> return a new time
|
||
|
object. <code class="code">add-duration!</code> and <code class="code">subtract-duration!</code> may modify
|
||
|
the given <var class="var">time</var> to form their return.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="SRFI_002d19-Date.html">SRFI-19 Date</a>, Previous: <a href="SRFI_002d19-Introduction.html">SRFI-19 Introduction</a>, Up: <a href="SRFI_002d19.html">SRFI-19 - Time/Date Library</a> [<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>
|