#!/usr/bin/perl package IkiWiki::Plugin::prettydate; use IkiWiki; use warnings; no warnings 'redefine'; use strict; sub default_timetable { # Blanks duplicate the time before. return [ #translators: These descriptions of times of day are used #translators: in messages like "last edited ". #translators: %A is the name of the day of the week, while #translators: %A- is the name of the previous day. gettext("late %A- night"), # 12 "", # 1 gettext("in the wee hours of %A- night"), # 2 "", # 3 "", # 4 gettext("terribly early %A morning"), # 5 "", # 6 gettext("early %A morning"), # 7 "", # 8 "", # 9 gettext("in mid-morning %A"), # 10 gettext("late %A morning"), # 11 gettext("at lunch time on %A"), # 12 "", # 1 gettext("%A afternoon"), # 2 "", # 3 "", # 4 gettext("late %A afternoon"), # 5 gettext("%A evening"), # 6 "", # 7 gettext("late %A evening"), # 8 "", # 9 # 9 gettext("%A night"), # 10 "", # 11 ]; } sub import { #{{{ hook(type => "checkconfig", id => "skeleton", call => \&checkconfig); } # }}} sub checkconfig () { #{{{ if (! defined $config{prettydateformat} || $config{prettydateformat} eq '%c') { $config{prettydateformat}='%X, %B %o, %Y'; } if (! ref $config{timetable}) { $config{timetable}=default_timetable(); } # Fill in the blanks. for (my $h=0; $h < 24; $h++) { if (! length $config{timetable}[$h]) { $config{timetable}[$h] = $config{timetable}[$h - 1]; } } } #}}} sub IkiWiki::displaytime ($) { #{{{ my $time=shift; eval q{use Date::Format}; error($@) if $@; my @t=localtime($time); my ($h, $m, $wday)=@t[2, 1, 6]; my $t; if ($h == 16 && $m < 30) { $t = gettext("at teatime on %A"); } elsif (($h == 0 && $m < 30) || ($h == 23 && $m > 50)) { # well, at 40 minutes it's more like the martian timeslip.. $t = gettext("at midnight"); } elsif (($h == 12 && $m < 15) || ($h == 11 && $m > 50)) { $t = gettext("at noon on %A"); } # TODO: sunrise and sunset, but to be right I need to do it based on # lat and long, and calculate the appropriate one for the actual # time of year using Astro::Sunrise. Not tonight, it's wee hours # already.. else { $t = $config{timetable}[$h]; if (! length $t) { $t = "sometime"; } } $t=~s{\%A-}{my @yest=@t; $yest[6]--; strftime("%A", \@yest)}eg; my $format=$config{prettydateformat}; $format=~s/\%X/$t/g; return strftime($format, \@t); } #}}} 1 option>space:mode:
authorJonas Smedegaard <dr@jones.dk>2023-06-27 09:35:08 +0200
committerJonas Smedegaard <dr@jones.dk>2023-06-27 09:35:08 +0200
commitfd54908da2b05c526dd3bee9b6dcd093214a220d (patch)
treec69c845069c99d1d01044f6fafda7c08433329c6 /tags/02/5d
parentba46132213560cf3335d53560d519c0ec0190da2 (diff)
master
Diffstat (limited to 'tags/02/5d')
-rw-r--r--tags/02/5d/0000014b2698cba1-b2e5ca2f-3a3a-4d09-ad10-b2d2c1ca849f-000000@email.amazonses.com/debian0
-rw-r--r--tags/02/5d/0000014b2698cba1-b2e5ca2f-3a3a-4d09-ad10-b2d2c1ca849f-000000@email.amazonses.com/unread0
-rw-r--r--tags/02/5d/1189002132.46debb94d06ca@impmail.munksoegaard.dk/inbox0
-rw-r--r--tags/02/5d/1189002132.46debb94d06ca@impmail.munksoegaard.dk/old0
-rw-r--r--tags/02/5d/20090729130935.GA11041@master.debian.org/debian0
-rw-r--r--tags/02/5d/20140403143907.GA77317@gwolf.org/debian0
-rw-r--r--tags/02/5d/20140403143907.GA77317@gwolf.org/signed0
-rw-r--r--tags/02/5d/20220526123747.02E16D8C@xayide.jones.dk/unread0
-rw-r--r--tags/02/5d/87lfd4xkwb.fsf@yucca/debian0
-rw-r--r--tags/02/5d/87lfd4xkwb.fsf@yucca/replied0
-rw-r--r--tags/02/5d/87lfd4xkwb.fsf@yucca/signed0
-rw-r--r--tags/02/5d/87lfd4xkwb.fsf@yucca/unread0
-rw-r--r--tags/02/5d/CACujMDMLPjq=BZTQrJLwApcHy2b9G=p8DDNbWo=A1vOub0v8tw@mail.gmail.com/debian0
-rw-r--r--tags/02/5d/CACujMDMLPjq=BZTQrJLwApcHy2b9G=p8DDNbWo=A1vOub0v8tw@mail.gmail.com/unread0
-rw-r--r--tags/02/5d/E1HkMLe-0000r0-0t@maintainer.skolelinux.no/debian0
-rw-r--r--tags/02/5d/F9580240D8F248A7ABCDA348973C3860@Art/sugar0
-rw-r--r--tags/02/5d/F9580240D8F248A7ABCDA348973C3860@Art/unread0
17 files changed, 0 insertions, 0 deletions