<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>curl &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/curl/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Mon, 01 Sep 2025 10:45:21 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>curl &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[A little oddity in the way curl deals with old dates]]></title>
		<link>https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/</link>
					<comments>https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 01 Sep 2025 11:34:48 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[time]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=63068</guid>

					<description><![CDATA[For boring technical reasons, computers think the world began on 1st of January 1970. To keep track of the future, they count the number of seconds since that momentous date.  So zero seconds represents midnight on that day.  So how do computers deal with dates before The Beatles&#039; Abbey Road was top of the UK album charts?  Negative numbers! Most modern computers can deal with dates far in the…]]></description>
										<content:encoded><![CDATA[<p>For boring technical reasons, computers think the world began on 1st of January 1970<sup id="fnref:who"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:who" class="footnote-ref" title="Although, who is to say it didn't? Were you there? Do you have proof? Maybe the Young Earth Creationists aren't ambitious enough?!" role="doc-noteref">0</a></sup>. To keep track of the future, they count the number of seconds since that momentous date.  So zero seconds represents midnight on that day<sup id="fnref:midnight"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:midnight" class="footnote-ref" title="Except! Psych! It doesn't! The UK was experimenting with year-round BST so there's actually an hour's difference. Time is hard™." role="doc-noteref">1</a></sup>.</p>

<p>So how do computers deal with dates <em>before</em> The Beatles' Abbey Road was top of the UK album<sup id="fnref:album"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:album" class="footnote-ref" title="Do not search for the number 1 single on that date. You'll give yourself a sad." role="doc-noteref">2</a></sup> charts?</p>

<p>Negative numbers! Most modern computers can deal with dates far in the past and, hopefully, far into the future. Again, for <a href="https://righteousit.com/2024/09/04/more-on-ext4-timestamps-and-timestomping/">boring technical reasons</a>, lots of computers can only save files with a date no earlier than 13th December 1901<sup id="fnref:book"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:book" class="footnote-ref" title="The music charts were less well-developed in 1901. But you could have read &quot;The Purple Cloud&quot; which is a brilliant early sci-fi novel." role="doc-noteref">3</a></sup>.</p>

<p>When you download a file from the Internet, the sending server can tell you when that file was last modified. That's useful if you only want to download the file if it has changed since you last got it.</p>

<p>It presents the date using <a href="https://www.rfc-editor.org/rfc/rfc1123">RFC 1123</a> format for reasons which are lost to the ages.</p>

<p><code>&lt; Last-Modified: Wed, 09 Oct 1940 16:45:49 +0100</code></p>

<p>Great!</p>

<p>If you use the venerable <code>wget</code> utility, it will happily save the file on your disk and tell you that is when it was created.</p>

<p>But what if you use <code>curl -OR</code> to download the file? The <code>-R</code> option says:</p>

<blockquote><p><a href="https://curl.se/docs/manpage.html#-R">Make curl attempt to figure out the timestamp of the remote file that is getting downloaded, and if that is available make the local file get that same timestamp. </a></p></blockquote>

<p>THIS IS A LIE!<sup id="fnref:lie"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:lie" class="footnote-ref" title="Everything you know is false! How deep does this conspiracy go!?!?" role="doc-noteref">4</a></sup></p>

<p>If curl sees a date with a negative time, it pretends that the past doesn't exist and that what you <em>really</em> wanted was to save the file with today's date and time.</p>

<p>Why does it do this?</p>

<p>I <em>think</em> it is because <a href="https://github.com/curl/curl/blob/f08ecdc586203026d1a81bd401486261f28848d3/src/tool_filetime.c#L89-L91">this code only checks for times ≥ 0</a>. Which, I guess, is pretty reasonable. There weren't <em>many</em> computers around before the 1970s<sup id="fnref:zero"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:zero" class="footnote-ref" title="Although, there were some. Not just the secret ones used to control the weather - but actual proper computers you could use to do maths!" role="doc-noteref">5</a></sup> so the chances of finding a file which predates disco are slim.</p>

<p>Should we storm the barricades and demand this temporal anomaly be rectified?<sup id="fnref:photon"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:photon" class="footnote-ref" title="Preferably by firing photon torpedoes. Or maybe ejecting the warp core. I'm not an engineer." role="doc-noteref">6</a></sup> Nah. I've <a href="https://github.com/curl/curl/discussions/18424">raised it as a discussion item on curl's GitHub</a>.</p>

<p>If you have strong opinions about this - please join in the discussion<sup id="fnref:help"><a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fn:help" class="footnote-ref" title="Or seek help from a mental health professional." role="doc-noteref">7</a></sup>.</p>

<div id="footnotes" role="doc-endnotes">
<hr aria-label="Footnotes">
<ol start="0">

<li id="fn:who">
<p>Although, who is to say it didn't? Were you there? Do you have proof? Maybe the Young Earth Creationists aren't ambitious enough?!&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:who" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

<li id="fn:midnight">
<p>Except! Psych! It doesn't! <a href="https://www.shellscript.sh/examples/1970/">The UK was experimenting with year-round BST</a> so there's actually an hour's difference. Time is hard™.&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:midnight" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

<li id="fn:album">
<p>Do not search for the number 1 <em>single</em> on that date. You'll give yourself a sad.&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:album" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

<li id="fn:book">
<p>The music charts were less well-developed in 1901. But you could have read "<a href="https://en.wikipedia.org/wiki/The_Purple_Cloud">The Purple Cloud</a>" which is a brilliant early sci-fi novel.&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:book" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

<li id="fn:lie">
<p>Everything you know is false! How deep does this conspiracy go!?!?&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:lie" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

<li id="fn:zero">
<p>Although, there were <em>some</em>. Not just the secret ones used to control the weather - but actual proper computers you could use to do maths!&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:zero" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

<li id="fn:photon">
<p>Preferably by firing photon torpedoes. Or maybe ejecting the warp core. I'm not an engineer.&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:photon" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

<li id="fn:help">
<p>Or seek help from a mental health professional.&nbsp;<a href="https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/#fnref:help" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

</ol>
</div>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=63068&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2025/09/a-little-oddity-in-the-way-curl-deals-with-old-dates/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[A small contribution to curl]]></title>
		<link>https://shkspr.mobi/blog/2025/02/a-small-contribution-to-curl/</link>
					<comments>https://shkspr.mobi/blog/2025/02/a-small-contribution-to-curl/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Tue, 11 Feb 2025 12:34:13 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[Open Source]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=58048</guid>

					<description><![CDATA[The venerable curl is one of the most fundamental pieces of code in the modern world.  A seemingly simply utility - it enables other programs to interact with URls - it runs on millions of cars, is inside nearly every TV, used by billions of people, and is even in use on Mars.  And, as of last week, features a small contribution by me!  Look, I&#039;m not an experienced bit-twiddler. I can&#039;t…]]></description>
										<content:encoded><![CDATA[<p>The venerable <a href="https://curl.se/">curl</a> is one of the most fundamental pieces of code in the modern world.  A seemingly simply utility - it enables other programs to interact with URls - it runs on <a href="https://daniel.haxx.se/blog/2018/08/12/a-hundred-million-cars-run-curl/">millions of cars</a>, is inside nearly every TV, used by <a href="https://daniel.haxx.se/blog/2021/04/22/so-what-exactly-is-curl/">billions of people</a>, and is even <a href="https://daniel.haxx.se/blog/2021/04/19/mars-2020-helicopter-contributor/">in use on Mars</a>.</p>

<p>And, as of last week, features a small contribution by me!</p>

<p>Look, I'm not an experienced bit-twiddler. I can't micro-optimise algorithms or spot intricate C-based memory leaks. What I <em>can</em> do is get annoyed at poor documentation!</p>

<p>You see, documentation and code comments are vitally important. Poor spelling might trip up non-native speakers, bad examples confuse learners, and ambiguous wording is a barrier to understanding.</p>

<p>As was written by the sages:</p>

<blockquote><p>a computer language is not just a way of getting a computer to perform operations but rather that it is a novel formal medium for expressing ideas about methodology. Thus, <strong>programs must be written for people to read, and only incidentally for machines to execute</strong>.
<cite>Abelson, Sussman, and Sussman <a href="https://web.mit.edu/6.001/6.037/sicp.pdf">Structure and Interpretation of Computer Programs</a></cite></p></blockquote>

<p>So, what did I fix? A few years ago, I noticed <a href="https://shkspr.mobi/blog/2020/01/even-google-forgets-to-renew-its-domains/">Google's documentation used example domains it didn't control</a>. The same thing was happening in the curl source code.</p>

<p>One example domain used was <code>"HTTPS://your.favourite.ssl.site"</code> - when that code was written 23 years ago, the .site TLD didn't exist. <a href="https://radix.website/dot-site">Now it does</a>.</p>

<p>Is there a serious risk that someone will register <code>ssl.site</code> and use it to take over the machine of anyone who unthinkingly follows that example? Probably not. But it also isn't terribly clear that it <em>is</em> an example. So I changed it to <code>secure.site.example</code> which uses the reserved <a href="https://en.wikipedia.org/wiki/.example"><code>.example</code></a> TLD.</p>

<p>That should make it clear to everyone that it is a placeholder example and will prevent anyone from misusing that domain.</p>

<p>Similarly, there were a few comments which used <code>domain.com</code> as an example. However, <a href="https://www.domain.com/">that's a real website</a> - so I updated those to <a href="https://example.com"><code>example.com</code></a>.</p>

<p>I was <em>delighted</em> to see the changes accepted.</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2025/02/curl-fs8.png" alt="daniel stenberg saying &quot;Welcome Terence Eden as #curl commit author 1342&quot;" width="1328" height="988" class="aligncenter size-full wp-image-58050">

<p>And I was only <em>slightly</em> disappointed to have narrowly missed out on being <a href="https://daniel.haxx.se/blog/2025/01/29/a-1337-curl-author/">contributor 1337</a>, but being number 1342 ain't so bad 😄</p>

<p>You can <a href="https://github.com/curl/curl/pull/16270/files">see the full list of changes on GitHub</a>.</p>

<p>Much like my <a href="https://lkml.org/lkml/2014/11/17/617">patch to the Linux Kernel</a> this might be considered a <a href="https://shkspr.mobi/blog/2014/04/submitting-trivial-linux-kernel-patches/">trivial matter</a> - but I honestly believe that clear and accurate documentation can be as important as the code itself.</p>

<p>Huge thanks to Daniel for creating curl, for making such a welcoming environment for new contributors, and for handing out such brilliant stickers at FOSDEM!</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2025/02/laptop-stickers.webp" alt="A laptop covered with stickers - prominent is curl." width="1024" height="768" class="aligncenter size-full wp-image-58150">
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=58048&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2025/02/a-small-contribution-to-curl/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
