[personal profile] ex_awakened208 posting in [community profile] style_system
In a date format that includes the day of the week in it, does anyone know how to replace the name of the day of the week with an image. For example, if I wanted to replace the text "Sat" with this image: a circle with the text "Sat" on it

This is the custom format I'm using for the date on the journal in question. Applied through theme layer.

Date: 2012-08-19 03:19 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Wow! This brings back memories!
Here's the code:

set entry_date_format = "short";
set lang_fmt_date_short = "%%mm%%/%%dd%%/%%yy%%";

function Entry::time_display(string datefmt, string timefmt) : string {
    var Page p = get_page();

var string day = $.time->date_format("%%day%%");

var string{} dayimage =
{
    "Monday" => "Monday.jpg",
    "Tuesday" => "Tuesday.jpg",
    "Wednesday" => "Wednesday.jpg",
    "Thursday" => "Thursday.jpg",
    "Friday" => "Friday.jpg",
    "Saturday" => "http://i1231.photobucket.com/albums/ee518/venbunny/Help/sat.gif",
    "Sunday" => "Sunday.jpg",
};

    var bool linkify = ( $p.view == "recent" or $p.view == "entry" or $p.view == "reply" or $p.view == "day" );

    if ($datefmt == "") { $datefmt = $*entry_date_format; }

    if ($timefmt == "") {

        if (viewer_logged_in()) {
            if (viewer_is_owner()) {
                $timefmt = $*entry_time_format;
            } else {
                if ($this.timeformat24) {
                    $timefmt = "short_24";
                } else {
                    $timefmt = "short";
                }
            }
        } else {
            $timefmt = $*entry_time_format;
        }

    } else {
        $timefmt = "short";
    }

    var string ret;
    if ($datefmt != "none") { $ret = $ret + """<span class="date"><img src="$dayimage{$day}" />""" + $this.time->date_format($datefmt, $linkify) + "</span>"; }
    if ($datefmt != "none" and $timefmt != "none") { $ret = $ret + " "; }
    if ($timefmt != "none") { $ret = $ret + """<span class="time">""" + $this.time->time_format($timefmt) + "</span>"; }

    if ($ret != "") { $ret = """<span class="datetime">$ret</span>"""; }

    return $ret;
}

All credit goes to kentucka from s2flexisquares over on LJ.
Edited Date: 2012-08-19 03:20 pm (UTC)

Profile

Dreamwidth style system discussion

October 2025

S M T W T F S
   1 234
567891011
12131415161718
19202122232425
262728293031 

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 5th, 2026 05:54 am
Powered by Dreamwidth Studios