RFP: MTSkipHours

If someone whose Perl skillz are a bit less lame than mine would like to do a Movable Type plugin that returns an RSS 0.9x/2.0 <skipHours> tag for a given set of local hours, that would be wonderful. I’m thinking along the lines of <MTSkipHours hours="23-6"> which would then return:

<skipHours>
<hour>7</hour>
<hour>8</hour>
<hour>9</hour>
<hour>10</hour>
<hour>11</hour>
<hour>12</hour>
<hour>13</hour>
<hour>14</hour>
</skipHours>

having first checked the timezone to determine that I’m in Pacific time, then determined that it’s now Standard Time rather than Daylight, and then converted my local time to UTC for the hours.

Update:

Thanks to the fantabulous Sam Ruby (with a little crappy code from me to turn it into an MT plugin): SkipHours plugin. Download, unzip, put SkipHours.pl in your plugins directory, and then put <$MTSkipHours hours=”23-6″$> in your RSS 0.9x/2.0 template to say that you will never update between 11 pm and 7 am your time, or in your RSS 1.0 template add the mod_RSS091 namespace (xmlns:rss091=”http://purl.org/rss/1.0/modules/rss091#”) to your namespace declaration, and then use <$MTSkipHoursRSS1 hours=”23-6″$> to add a <rss091:skipHours> element to your RSS 1.0 file.

Caveat: like MTDaylightOrStandard, you do need live in the same timezone as your server.

Update Two: oops, I forgot the rdf:parseType=”Literal” in the skipHours element for RSS 1.0, so if you already installed the plugin and are using it in RSS 1.0, you need to grab a new copy to be truly compliant. Sorry about that.

5 Comments

Comment by Sam Ruby #
2002-11-10 20:07:36

I don’t know MT, but I do know Perl… here’s a command line program which will do the dirty deed:

use strict;
use Time::Local;
my ($start,$end) = split(/-/,shift);
$end ||= $start;
$end += 24 if $start > $end;
print "<skipHours>n";
my @ltime = localtime();
for (my $i=$start; $i<=$end; $i++) {
  $ltime[2]=$i % 24;
  my @gtime = gmtime(timelocal(@ltime));
  print "<hour>$gtime[2]</hour>n";
}
print "</skipHours>n";
 
Comment by Phil Ringnalda #
2002-11-10 21:11:26

Well, I don’t really know MT, but I’m pretty damn good at copying things and tweaking them a bit, so I was able to turn that into an MT plugin that actually worked the first time, though I think I may have wasted an extra twenty characters or so (did Larry Wall have a keyboard that shocked him on every keypress when he was designing Perl?). Thank you Mr. Ruby, you’re a wizard.

 
Comment by Christine #
2003-04-14 14:08:11

If you don’t live in the same time zone as your server, can you set the hours to be the hours in the server timezone? For example, I live in the Central time zone, my server is Eastern. I never post between 2am – 7am my time (3am – 8am there). Could I set it to MTSkipHours hours=2-7?

Comment by Phil Ringnalda #
2003-04-14 21:43:09

Wouldn’t you want to use hours=3-8? The plugin converts the hours that you give it, in the server’s timezone, to GMT, so if you don’t post from 3-8 Eastern, you should tell it 3-8. I’m pretty sure that’s right, though the reason I needed a plugin was that I’m terrible with timezone conversions. If you aren’t, you might want to figure out what hours your 2-7 is in GMT, try 3-8, and see if you get the right hours in your feed.

 
 
Trackback by MT Plugin Directory #
2003-01-30 13:56:08

SkipHours

You must live in the same timezone as your server for this to work correctly. Base code adapted from Sam

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <del datetime="" cite=""> <dd> <dl> <dt> <em> <i> <ins datetime="" cite=""> <kbd> <li> <ol> <p> <pre> <q cite=""> <samp> <strong> <sub> <sup> <ul> in your comment.