Skip to content

Instantly share code, notes, and snippets.

@jbenner-radham
Last active August 29, 2015 14:19
Show Gist options
  • Save jbenner-radham/8fdbc78c2ac50516a2d9 to your computer and use it in GitHub Desktop.
Save jbenner-radham/8fdbc78c2ac50516a2d9 to your computer and use it in GitHub Desktop.
Draft for my "rfc1123_gmt_timestamp.mandoc_mdoc.3" man page.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>
table.head, table.foot { width: 100%; }
td.head-rtitle, td.foot-os { text-align: right; }
td.head-vol { text-align: center; }
table.foot td { width: 50%; }
table.head td { width: 33%; }
div.spacer { margin: 1em 0; }
</style>
<title>
RFC1123_GMT_TIMESTAMP(3) (prm)</title>
</head>
<body>
<div class="mandoc">
<div class="section">
<h1 id="x4e414d45">NAME</h1> <b class="name">rfc1123_gmt_timestamp</b> &#8212; <span class="desc">creates an RFC 1123 GMT formatted timestamp<div class="spacer">
</div>
</span></div>
<div class="section">
<h1 id="x53594e4f50534953">SYNOPSIS</h1> <b class="includes">#include &lt;<a class="link-includes">rfc1123_gmt_timestamp.h</a>&gt;</b><div class="spacer">
</div>
<br/>
<span class="type">enum</span> <b class="var">RFC1123_GMT_LEN</b>, <b class="var">RFC1123_GMT_SIZE</b>;<div class="spacer">
</div>
<br/>
<i class="ftype">static inline int</i><br/>
<b class="fname">rfc1123_gmt_timestamp</b>(<i class="farg">char</i>, <i class="farg">*restrict</i>, <i class="farg">dest</i>, <i class="farg">const</i>, <i class="farg">time_t</i>, <i class="farg">*restrict</i>, <i class="farg">timer</i>);</div>
<div class="section">
<h1 id="x4445534352495054494f4e">DESCRIPTION</h1> The <b class="name">rfc1123_gmt_timestamp</b>() function takes a pointer to <i class="farg">timer</i> and formats it as a string via &#8220;%a, %d %b %Y %T GMT&#8221; which is then stored in the <i class="farg">dest</i> buffer.</div>
<div class="section">
<h1 id="x52455455524e2056414c554553">RETURN VALUES</h1> Upon successful completion, the value of <b class="var">RFC1123_GMT_LEN</b> is returned; otherwise the value&#160;0 is returned to indicate the error.</div>
<div class="section">
<h1 id="x4558414d504c4553">EXAMPLES</h1> The following code gets the current Unix time and creates a RFC 1123 GMT formatted timestamp string.<div class="spacer">
</div>
<pre style="margin-left: 5.00ex;" class="lit display">
char ts[RFC1123_GMT_SIZE] = {0};
int tslen;
time_t t;
t = time(NULL);
if (t == (time_t)(-1)) {
/** Error handling would go here... */
exit();
}
tslen = rfc1123_gmt_timestamp(ts, &amp;t);
if (tslen != RFC1123_GMT_LEN) {
/** Error handling would go here... */
exit();
}
printf(&quot;%.*s\n&quot;, RFC1123_GMT_LEN, ts);</pre>
</div>
<div class="section">
<h1 id="x53454520414c534f">SEE ALSO</h1> <span class="ref"><span class="ref-auth">Braden, R., Ed.</span>, <span class="ref-title">Requirements for Internet Hosts - Application and Support</span>, <span class="ref-rep">STD 3, RFC 1123</span>, <a class="link-ref" href="&lt;http://www.rfc-editor.org/info/rfc1123&gt;">&lt;http://www.rfc-editor.org/info/rfc1123&gt;</a>, <span class="ref-corp">IETF Host Requirements Working Group</span>, <span class="ref-date">October 1989</span>.</span><div class="spacer">
</div>
<span class="ref"><span class="ref-auth">Crocker, D.</span>, <span class="ref-title">Standard for the Format of ARPA Internet Text Messages</span>, <span class="ref-rep">STD 11, RFC 822</span>, <a class="link-ref" href="&lt;http://www.rfc-editor.org/info/rfc822&gt;">&lt;http://www.rfc-editor.org/info/rfc822&gt;</a>, <span class="ref-corp">IETF Host Requirements Working Group</span>, <span class="ref-date">August 1982</span>.</span></div>
<div class="section">
<h1 id="x5354414e4441524453">STANDARDS</h1> Conforms to IETF RFC-1122 (sec. 5.2.14).</div>
<div class="section">
<h1 id="x415554484f5253">AUTHORS</h1> <span class="author">James Benner</span></div>
</div>
</body>
</html>
.Dd $Mdocdate$
.Dt RFC1123_GMT_TIMESTAMP 3 PRM
.Os rfc1123_gmt_timestamp 0.0.0
.\"
.Sh NAME
.\" ====
.Nm RFC1123_GMT_TIMESTAMP
.Nd creates an RFC 1123 GMT formatted timestamp
.Pp
.Sh SYNOPSIS
.\" ========
.In rfc1123_gmt_timestamp.h
.Pp
.Vt enum
.Va RFC1123_GMT_LEN ,
.Va RFC1123_GMT_SIZE ;
.Pp
.Ft static inline int
.Fo rfc1123_gmt_timestamp
.Fa char *restrict dest
.Fa const time_t *restrict timer
.Fc
.\"
.Sh DESCRIPTION
.\" ===========
The
.Nm Ns ()
function takes a pointer to
.Fa timer
and formats it as a string via
.Dq "%a, %d %b %Y %T GMT"
which is then stored in the
.Fa dest
buffer.
.\"
.Sh RETURN VALUES
.\" =============
Upon successful completion, the value of
.Va RFC1123_GMT_LEN
is returned; otherwise the value 0 is returned to indicate the error.
.\"
.Sh EXAMPLES
.\" ========
The following code gets the current Unix time and creates a RFC 1123 GMT
formatted timestamp string.
.Pp
.Bd -literal -offset indent -compact
char ts[RFC1123_GMT_SIZE] = {0};
int tslen;
time_t t;
t = time(NULL);
if (t == (time_t)(-1)) {
/** Error handling would go here... */
exit();
}
tslen = rfc1123_gmt_timestamp(ts, &t);
if (tslen != RFC1123_GMT_LEN) {
/** Error handling would go here... */
exit();
}
printf("%.*s\\n", RFC1123_GMT_LEN, ts);
.Ed
.\"
.Sh SEE ALSO
.\" ========
.Rs
.%A Braden, R., Ed.
.%T "Requirements for Internet Hosts - Application and Support"
.%R STD 3, RFC 1123
.%Q IETF Host Requirements Working Group
.%D October 1989
.%U <http://www.rfc-editor.org/info/rfc1123>
.Re
.\"
.Rs
.%A Crocker, D.
.%T "Standard for the Format of ARPA Internet Text Messages"
.%R STD 11, RFC 822
.%Q IETF Host Requirements Working Group
.%D August 1982
.%U <http://www.rfc-editor.org/info/rfc822>
.Re
.Sh STANDARDS
.\"=========
Conforms to IETF RFC-1122 (sec. 5.2.14).
.\"
.Sh AUTHORS
.\" =======
.An James Benner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment