Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Not using "non-breaking hyphen" U+8209 in timestamps

by jdporter (Canon)
on Jan 15, 2011 at 23:52 UTC ( #882483=monkdiscuss: print w/replies, xml ) Need Help??

For some time now, the monastery has been returning timestrings with the date parts separated by the Unicode "non-breaking hyphen" character, U+8209. I just changed the relevant code (the two places I could find) to use a regular hyphen character, because while the U+8209 character displays just fine in normal HTML text in a browser, it doesn't DWIM in any other context (afaik), of which there are many, including in normal web browsing — For example, when using it in the title attribute of an element, which gets displayed as a Tooltip in some (most?) browsers. (The general principle there is that attribute values are not supposed to be HTML.) (To see this in action, go to the Chatterbox (or last hour of cb) and hover your pointer on the name of a chatterer. The tooltip shows the date/time at which that message was chatted.)

Please tell me what, if anything, I've broken in exchange for this rather substantial fix.

What is the sound of Windows? Is it not the sound of a wall upon which people have smashed their heads... all the way through?

Replies are listed 'Best First'.
Re: Not using "non-breaking hyphen" U+8209 in timestamps (thanks)
by tye (Sage) on Jan 16, 2011 at 02:32 UTC

    Yeah, I've been contemplating making that same change. There are several places where dates are displayed in tables and my experience was that browsers were pretty stupid and frequently chose to make the date column too narrow such that every single row became two lines high. Preventing browsers from making this choice mostly lead to better presentation where the widest column (usually 'title') was made narrower and most rows would be single lines and only the rows with the longest titles took up two lines. And wrapping of titles is less of a problem than wrapping something regular like a date -- where you lose having the years lined and now have numbers lined up vertically but only every other one is a year, making the information much harder to scan.

    But that improvement isn't worth the ugliness that shows up in many contexts. I was thinking that this change was a change I had made only to my personal settings. But I think we lack a personal setting for "how to format dates compactly" so there are several tables that just hard-code the formatting of dates.

    - tye        

        No, we don't want to s/-/‑/g for everybody, as some people have environments where that character doesn't render properly (the Wii browser for one, it seems).

        Frankly, most people don't have this problem because they are used to the age of CSS when at least a near majority of web pages are at least inconvenient to read if you don't maximize your browser and also have a fairly modern-sized monitor.

        I find that most computer users I meet either only use maximized windows or hardly ever use maximized windows. The latter group is in the minority but counts me as a member. So I find myself constantly disabling CSS just so I can frickin' read the dang text on a stupid web page.

        So I likely have my browser window about 1/2 the width of the majority of people and so I see wrapped text in tables at PerlMonks more than most.

        So, the few of us who actually still make use of a windowing system should be enabled to set our 'shorttimeformat' to "%Y&#8209;%m&#8209;%d&nbsp;%H:%M" or "<nobr>%Y-%m-%d %H:%M</nobr>" but then have that transformed into something for the non-HTML contexts (like 'title' attributes), perhaps via things like s/&#8209;/-/g and s/&nbsp;/ /g and s/<[^>]+>//g. So we need to teach the code to ask for an HTML compact date or a text compact date.

        But probably better would be to allow for each time format to specify separate formats for HTML vs. text. I'd probably just stuff that into the existing format settings. I'd be tempted to use "</html>" as the separator so we don't have allow for escaping the separator. For example, "<nobr>%Y-%m-%d&#x1F551;%H:%M</nobr></html>%Y-%m-%d %H:%M".

        - tye        

Re: Not using "non-breaking hyphen" U+8209 in timestamps
by MidLifeXis (Monsignor) on Jan 18, 2011 at 14:36 UTC

    As (one of?) the reported failures of the Wii browser's rendering of ‑, I was surprised at the quick patch to fix this (thank you, BTW). I don't intend to use the Wii for my normal browsing (definitely needs a keyboard - the controller just does not do it :-), but was playing around with a new "toy" to see what it could do.

    Does this fix have value beyond just a couple of "fringe" browsers? It seems, from your commentary here that there are a couple of other nagging problems that this fixes as well. Is that correct?


      Yes, there are places where dates are used where HTML is not allowed, for example, in <span title="$date">.

      - tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://882483]
Approved by Corion
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-10-20 08:06 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (259 votes). Check out past polls.