Terence Eden. He has a beard and is smiling.
Theme Switcher:

A little oddity in the way curl deals with old dates

· 3 comments · 550 words · Viewed ~469 times


For boring technical reasons, computers think the world began on 1st of January 19700. To keep track of the future, they count the number of seconds since that momentous date. So zero seconds represents midnight on that day1.

So how do computers deal with dates before The Beatles' Abbey Road was top of the UK album2 charts?

Negative numbers! Most modern computers can deal with dates far in the past and, hopefully, far into the future. Again, for boring technical reasons, lots of computers can only save files with a date no earlier than 13th December 19013.

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.

It presents the date using RFC 1123 format for reasons which are lost to the ages.

< Last-Modified: Wed, 09 Oct 1940 16:45:49 +0100

Great!

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

But what if you use curl -OR to download the file? The -R option says:

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.

THIS IS A LIE!4

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

Why does it do this?

I think it is because this code only checks for times ≥ 0. Which, I guess, is pretty reasonable. There weren't many computers around before the 1970s5 so the chances of finding a file which predates disco are slim.

Should we storm the barricades and demand this temporal anomaly be rectified?6 Nah. I've raised it as a discussion item on curl's GitHub.

If you have strong opinions about this - please join in the discussion7.


  1. Although, who is to say it didn't? Were you there? Do you have proof? Maybe the Young Earth Creationists aren't ambitious enough?! ↩︎

  2. Except! Psych! It doesn't! The UK was experimenting with year-round BST so there's actually an hour's difference. Time is hard™. ↩︎

  3. Do not search for the number 1 single on that date. You'll give yourself a sad. ↩︎

  4. The music charts were less well-developed in 1901. But you could have read "The Purple Cloud" which is a brilliant early sci-fi novel. ↩︎

  5. Everything you know is false! How deep does this conspiracy go!?!? ↩︎

  6. Although, there were some. Not just the secret ones used to control the weather - but actual proper computers you could use to do maths! ↩︎

  7. Preferably by firing photon torpedoes. Or maybe ejecting the warp core. I'm not an engineer. ↩︎

  8. Or seek help from a mental health professional. ↩︎


Share this post on…

3 thoughts on “A little oddity in the way curl deals with old dates”

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

See allowed HTML elements: <a href="" title="">
<abbr title="">
<acronym title="">
<b>
<blockquote cite="">
<br>
<cite>
<code>
<del datetime="">
<em>
<i>
<img src="" alt="" title="" srcset="">
<p>
<pre>
<q cite="">
<s>
<strike>
<strong>

To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.