Movable Type Bloggers: A Neat Tip

This is for Linux users, but there are ways to implement it on Windows and Mac boxes (but you are on your own.)If you use the movable type interface, you will know that when you generate a “Create New Entry” page, the current date is placed in the “Entry Date” filed. But, as time passes, that date does not change. So, if you work on this post for an hour, the date of your post is now an hour stale. You get the point.To fix this, you need to adjust the date before you “Publish” the post. But the date has to be in exactly the same format. And the time zone you are publishing on may not be the time zone you live in. And so on.I have a solution.I have a little script that you can have. I have a terminal window open, and when I type in “now” (the name of the executable script), I get a string of numbers that is the exact format Movable type requires, in EST (I live in CST). I can copy and paste this into the Entry Date field.You may need to adjust the script to have your own time zone adjustment (or no adjustment at all). It should be obvious how to do this.Put the script in a text file in your “bin” directory (which in turn should be on your PATH) and chmod it to make it executable.Here is the script:#/bin/bash## outputs a date in MT format one hour from now (thus EST)## REVISE LATER: Zap this output into the clipboard#date -d '+1 hour' '+%Y-%m-%d %H:%M:%S'And here is what it looks like when it runs:greg@greg-desktop:~$ now2008-02-26 08:19:08In the near future, I’ll revise this to make it more useful, but let me tell you what that will involve in case you want to start working on this now. I’ll pipe the output of this script to a python or perl app that will insert it onto the clipboard. Then, I’ll make a button on my Gnome task bar that runs the script. So, all I’ll need to get the current date is to hit the button and the date in on the clipboard ready to be pasted.The next step after that, of course, is to have a bit of perl code that finds the web page and sticks the data into the appropriate field. I have no idea how to do this, but how hard can it be?Then, the next obvious step is to run this script with the use of my new Mind Control Helmet.

Share and Enjoy:
  • Twitter
  • StumbleUpon
  • Facebook
  • Digg
  • Yahoo! Buzz
  • Google Bookmarks
  • LinkedIn

4 thoughts on “Movable Type Bloggers: A Neat Tip

  1. Zap this output into …

    Ah! Someone else who still(?) uses “zap” and (I presume) “crunch” for I/O redirections. Haven’t seen or heard that terminology in ages….

  2. Your example depends on the Linux/GNU date binary. People on older UNIX systems would have to use the following:TZ=EST5EDT '+%Y-%m-%d %H:%M:%S'But if you have access to Perl, you can likely use:#!/usr/bin/perluse strict;use warnings;use POSIX qw(strftime);print strftime(q(%Y-%m-%d %H:%M:%S), localtime(time()+3600)), "n";orperl -MPOSIX=strftime -e "print strftime(q(%Y-%m-%d %H:%M:%S), localtime(time+3600)), qq(n);" (Tested under cygwin, Active State perl (Windows XP), and Solaris.)

  3. In Python, the way you do this is very similar to Perl.>>> from time import strftime, localtime, time>>> print strftime("%Y-%m-%d %H:%M:%S", localtime(time()+3600)) + "n"In C, which Python and Perl closely follow, here is a program which works on cygwin. (Your milage may vary.)#include #include #include Now, that is why Python and Perl exist.

Leave a Reply

Your email address will not be published.