Want more features on Pastebin? Sign Up, it's FREE!
Guest

xkcdtimetemplate

By: a guest on May 12th, 2013  |  syntax: Perl  |  size: 0.99 KB  |  views: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2. #
  3.  
  4. use strict;
  5. use warnings;
  6. use Time::Piece;
  7. use Time::Seconds;
  8.  
  9. if ($#ARGV != 0) {
  10.   print "usage: imgtemplate daynumber\n";
  11.   exit;
  12. }
  13.  
  14. my $day = $ARGV[0];
  15.  
  16. my $imgnumber = 97 + 24*$day;
  17. my $timeval = -24 + 24*$day;
  18.  
  19. my $i=0;
  20.  
  21. my $datetime = Time::Piece->strptime("2013-03-24", "%Y-%m-%d");
  22.  
  23. $datetime += ONE_DAY*$day;
  24.  
  25. print "====Day $day, ", $datetime->fullday, ", ", $datetime->fullmonth, " ", $datetime->mday, ", ", $datetime->year, "====\n";
  26. print "{| class=\"wikitable plainlinks table-padding mw-collapsible mw-collapsed\"\n";
  27. print "|-\n";
  28. print "!Image\n";
  29. print "!Time\n";
  30. print "!Original image hash\n";
  31. print "|-\n";
  32.  
  33.  
  34. for ($i=0; $i<=23; $i++)
  35. {
  36.   if($i < 10)
  37.   {
  38.     print "|[[Media:time", $imgnumber, ".png|", $timeval, ":00]]||", $day, "/0", $i, ":00||\n";
  39.   }
  40.   else
  41.   {
  42.     print "|[[Media:time", $imgnumber, ".png|", $timeval, ":00]]||", $day, "/", $i, ":00||\n";
  43.   }
  44.   print "|-\n";
  45.   $imgnumber++;
  46.   $timeval++;
  47. }
  48.  
  49. print "|}\n";
clone this paste RAW Paste Data