Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Correct and nicely format the date ranges for pages.
Browse files Browse the repository at this point in the history
An endash is appropriate typographically for ranges.
The subquery ensures the LIMIT/OFFSET is respected in the min/max.
And now I'm using the system time format.
  • Loading branch information
Adrian Cochrane committed Mar 16, 2018
1 parent efe1e1c commit 37ac6b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions data/pages/history
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ and to visually communicate the paths surfers took through this history. #}
{% each-row %}
{% for i in num_pages %}
{% if i != url.query.page %}<a href="odysseus:history?page={{i}}"{% else %}<strong {% endif %}
{% query %}SELECT min(visited_at) AS earliest, max(visited_at) AS latest FROM page_visit
LIMIT {{pagesize}} OFFSET {{i}}*{{pagesize}};
{% query %}SELECT min(visited_at) AS earliest, max(visited_at) AS latest
FROM (SELECT visited_at FROM page_visit
ORDER BY visited_at DESC LIMIT {{pagesize}} OFFSET {{i}}*{{pagesize}});
{% each-row %}
title="{{latest}} - {{earliest}}"
title="{{latest|date}}–{{earliest|date}}"
{% endquery %}
>●</{% if i != url.query.page %}a{% else %}span{% endif %}>
{% empty %}
Expand Down
5 changes: 4 additions & 1 deletion src/Services/Prosody/lib.vala
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,10 @@ namespace Odysseus.Templating.Std {
private class DateFilter : Filter {
public override Data.Data filter(Data.Data date, Data.Data format) {
var datetime = new DateTime.from_unix_local(date.to_int());
var ret = datetime.format(format.to_string());
var format_str = format.to_string();
if (format_str == "")
format_str = @"$(Granite.DateTime.get_default_date_format()) $(Granite.DateTime.get_default_time_format())";
var ret = datetime.format(format_str);
return new Data.Literal(ret);
}
}
Expand Down

0 comments on commit 37ac6b8

Please sign in to comment.