KBD

Keith Devens .com

Monday, December 1, 2008 Flag waving
Mongol General: "What is best in life?" Conan: "To crush your enemies, to see them driven before you, and to... – Conan (Conan the Barbarian)

Archive: August 17, 2004

← August 16, 2004August 18, 2004 →

Daily link icon Tuesday, August 17, 2004

  1. Jayson at PoliPundit has been doing a whole series of posts comparing the economic environment of 1996, under which Clinton was re-elected, to the current economic environment, each time showing how by just about every measure the economy is equal or better than it was in 1996. I think the most recent post is the most striking to me because it covers wages, which is one of the things Kerry has been complaining loudest about.

       (0) Tags: [Opinions/Politics]
  2. Dirify in PHP :: Kalsey Consulting Group. Mimics Movable Type's "dirify" function in PHP.

       (0) Tags: [Programming]

Leap seconds

I was kind of surprised to realize, while in the bath, that simply adding 86,400 to some timestamp isn't enough to get you the next day. Because of leap seconds, you might wind up with something that's not a full day forward from the current day (in other words, the time will be different), and it's conceivable, though extremely unlikely, that you could still wind up with a timestamp representing the same day.

If your language doesn't have some "date_add" function, it seems the only way to do date math, given a timestamp, is to split the timestamp apart using strftime and then stick it back together again using mktime while adding a day. Straightforward, but cumbersome. Unfortunately, it seems that's the only way to really do correct date math, assuming, of course, that the underlying system libraries account for leap seconds.

Of course, this is one of those things that's so rare you can safely ignore it, but if you're anal about correctness like me it'll probably irk you enough to do it the "right" way.

Update: Oops, not to mention daylight savings time, which can also make a day longer or shorter than 86,400 seconds. That's a much more common occurrence, of course, and it's something you shouldn't ignore in your code.

Here's a real-life bug caused by this fact.

Update: I can't believe I'm going to have to write my own function to handle this in PHP. Incidentally, Javascript has some of the best date handling support of any language.

Update: I was also worried that this would affect how I handle time conversion between local and GMT (UTC), but luckily leap seconds happen around the world at the exact same time:

Leap seconds can occur only at the end of a month, and have only ever occurred at the end of a 30 June or 31 December. Unlike leap days, they occur simultaneously worldwide; for example, a leap second on 31 December will be observed as 7:59:60 pm U.S. Eastern Standard Time.

So, it's still ok to calculate UTC with reference to my local timezone and its offset in seconds from UTC. Whew Smiley

Update: Between some of the above updates I did a grep on the WordPress source and found that they do the same thing (add 86,400 seconds to things). Once I get my date handling resolved, I'll probably send my function over to them. If I wind up with something that works well, I should probably submit a patch to PHP as well.

Update: Hahahahaha, the EcmaScript specification stipulates that leap seconds are ignored in its date handling! See page 117.

Update: Matt linked to this, and ramin pointed out in a comment that strtotime does increments, which I didn't realize. So, I can simply say $time = strtotime('+1 day',$time); and that handles it.

Also, one of the things I've been wondering is what numeric value you get when you have a fall daylight savings time (where your time gets set back an hour). In that case, you'll have two times that are the same time (i.e. two 1:30am's). Each has a unique reference point in UTC, but strtotime has to arbitrarily pick one when you ask for a timestamp in that limbo period.

  1. For whatever reason I just remembered I forgot to blog this a while ago: The Ideological War Within the West. Originally via LGF, but it's also in Steven Den Beste's Essential Library, so it's a must-read.

       (0) Tags: [Opinions/Politics]

Sir Ian McKellen on stardom

I just came across some of the wisest comments I've ever heard/read on stardom, from Sir Ian McKellen:

TW: Do you have more young fans now that you’ve done some kid-friendly movies?
IM: Oh, yes. I’m more recognized by people of all ages. I haven’t yet seen the downside of that. It’s been nothing but good. But to become famous at 64 is perhaps easier than to become famous at 18. Now I know it’s not me who’s famous. Well, I’m only famous as the man who played Gandalf. I’m famous as the man who played Magneto. But I’m not patting myself on the back. It’s luck that I got those parts, or at least good management. I didn’t go after them. They just came my way. But I would much rather be famous as Gandalf’s representative than as Ian McKellen, because people don’t come and ask me questions about my private life, which I don’t want to answer. But I’m quite happy to talk about Gandalf, as I’m doing now.

Emphasis mine.

  1. Search Engine Highlighting -- some PHP code that allows you to highlight words on a page in response to a searh request. I haven't looked at the code yet. What's nice about all my pages being XHTML is that if I want to I can do this type of thing in a non-hacky manner by using DOM-enabled Javascript or a server-side XSLT transformation.

       (0) Tags: [Programming, This website]
  2. The Smallest Minority links to a 12 minute ad (to watch) chronicling Kerry's statements on Iraq (Real Player, Windows Media). I don't know where he originally got those links from. If anyone knows where the official page for the video is, please send it along.

       (1) Tags: [Opinions/Politics]
  3. This seems like a pretty good tutorial on CSS positioning: Integrated Web Design: Position This! CSS Positioning Demystified, via Paul.

       (0) Tags: [Programming]
  4. The people from the merd language project have put together a study of syntax across languages, via The Farm.

       (0) Tags: [Programming]
  5. After laughing really hard at this Achewood strip (via Wunderkinder) I'm thinking of adding Achewood to my "must reads" over there on the right.

       (1)
  6. The Daily WTF has what's probably the biggest, most intentional security hole I've ever seen: Avoiding the dreaded Refresh.

       (0) Tags: [Programming]

Wired News: It's Just the 'internet' Now

Wired News: It's Just the 'internet' Now, via Paul. I want to agree with them and adopt the same conventions, but the Internet isn't quite the same as television. Note, the Internet. You don't say "the television", except when you're speaking about the physical box.

The Internet is a particular network, which uses TCP/IP, does name resolution with DNS, etc. In contrast, HDTV, even though it comes over cable or satellite, and uses different standards and has a different resolution than "normal" television, is still television.

  1. Cox & Forkum: For al-Sadr?. The cartoon made me physically ill, and rightly so. Read the rest of the entry as well.

       (0) Tags: [Opinions/Politics]

Woo, featured on LockerGnome

Woo, my programmer fonts page has been featured on LockerGnome.

  1. Advanced Bash-Scripting Guide, via Kayode.

       (0) Tags: [Programming]
  2. StopIE: Help stop Internet Explorer, the worlds most popular and worst internet browser - StopIE.com. Via Kayode.

       (0)
  3. User Authentication on the World Wide Web - Weblog - Xiven.com, via Kayode. Use cookies and like it. There is no other generally applicable solution. HTTP Authentication can be useful sometimes, but not most of the time.

       (0) Tags: [Programming]
  4. Max Design - A webstandards checklist, via Kayode.

       (1) Tags: [Programming]
  5. Donald Sensing: SEAL Teams to Cambodia?. This is a 35 year old story that keeps mutating. What the hell?

    If I ever have children, I think I'll use this as an example of what happens when you lie. It's harder to admit you lied than to tell other lies in an attempt to cover up the original lie, so the lies keep coming.

       (0) Tags: [Opinions/Politics]
  6. Lorie Byrd at PoliPundit: "As insane as one cable news channel, Fox News, seems to drive liberals, I cannot even imagine how they would fare for one day in the skin of a conservative." Heh.

       (0) Tags: [Opinions/Politics]
← August 16, 2004August 18, 2004 →
December 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 6 posts

Recent comments XML

new⇒Perl 6 1.0 in March?

No, Parrot is not Perl 6.  Parrot​is a prerequisite for Rakudo Perl​1.0, bu...

Andy Lester: Dec 1, 8:40pm

new⇒Free image hosting sites

Well, TinyPic has this in its​FAQ:

> Images and videos is in​your accoun...

Keith: Dec 1, 1:13am

Join a NameValueCollection into a querystring in C#

Well with a lamba expression, this​is what I came up​with:

?!code:csharp...

Gustaf Lindqvist: Nov 30, 4:38pm

Why no generic OrderedDictionary?

Check​http://www.codeproject.com/KB/recip​es/GenericOrderedDictionary.aspx?d...

Gabrielk: Nov 27, 6:57am

WhatIsMyIP.com

http://www.thesysteminfo.com is​another good alternate to​whatismp.com... I...

Kripz: Nov 26, 8:51pm

Girls, please don't get breast implants

Actually I think it's sweet when a​man loves a woman whether she's big​or n...

218.186.12.228: Nov 26, 9:40am

Generated in about 0.087s.

(Used 7 db queries)

mobile phone