Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let RainTPL handle date formatting #144

Closed
alexisju opened this issue Mar 5, 2015 · 8 comments
Closed

Let RainTPL handle date formatting #144

alexisju opened this issue Mar 5, 2015 · 8 comments
Milestone

Comments

@alexisju
Copy link

alexisju commented Mar 5, 2015

As you know, date's formatting depends of the server's configuration.This causes some difficulties:

  • Local problem (for example, if the server is configured in English, the date will not be displayed in your usual format, which can be uncomfortable for the user).
  • The format is not necessarily the one I want to use my template (and having to hack index.php is not what there is of more convenient)

Specifically, in the case of AlbinoMouse on the shared hosting I use, I have to edit the index.php file to force the local French (setlocale (LC_TIME, 'en_US', 'eng')).

The result is "jeu. 05 March 2015 18:30:15 CET."

But if I want to display the date differently, for example in the format d / m / Y, it's impossible to do that by changing my template.

@ArthurHoaro for his personal shaarli uses a hack index.php to display the date it this way (d / m / Y): http://git.hoa.ro/arthur/links/blob/master/index.php#L1802

Another aspect is that of privacy (hiding timestamp) when sharing her with RSS Shaarlo: if totally mask the date and time, it does not work. But it's maybe possible to hide time into linklist/daily and preserve it into the rss...

@ArthurHoaro
Copy link
Member

I did a ugly hack, but I think we can do better with RainTPL like this. We just need to provide the timestamp instead of formatted date.

About RSS datetime, I wouldn't recommand changing it since RSS Reader (such as Shaarlo) might use it to retrieve or order their shaare.

@nodiscc
Copy link
Member

nodiscc commented Mar 5, 2015

I'd be ok with letting RainTPL parse and format dates (index.php would just pass a timestamp), but Shaarli currently formats the date/time depending on the browser locale (Accept-Language HTTP request header) and I don't know if RainTPL can do the same thing.

But it's maybe possible to hide time into linklist/daily and preserve it into the rss...

No. HIDE_TIMESTAMPS should be respected everywhere.

@nodiscc nodiscc changed the title About date's formatting Let RainTPL handle date formatting Mar 9, 2015
@nodiscc nodiscc added enhancement cleanup code cleanup and refactoring and removed feedback needed need info labels Mar 9, 2015
@mro
Copy link

mro commented Mar 10, 2015

I once used a pure client-side human-friendly date formatting via http://momentjs.com/. Server deals with ISO8601 only. Target locale could maybe sit in a cookie.

see here: http://rec.mro.name/stations/b2/2015/03/10/0605%20radioWelt.xml#date

@nodiscc
Copy link
Member

nodiscc commented Mar 12, 2015

@ArthurHoaro @alexisju do you want to send a pull request to change date format handling (generate a timestamp in index.html, render it in template)? This should be done before work on #163 is finished because it introduces changes to the templates (add date rendering code to them).

@alexisju
Copy link
Author

(I don't know how to do that... but it will be nice indeed

@ArthurHoaro
Copy link
Member

I'll try do something about it.

@ArthurHoaro
Copy link
Member

I don't know for you guys, but autoLocale() doesn't work at all. My browser (firefox, Fedora) sends fr,en-us in header request and neither are valid parameter for setlocale. I'll work on that first.

@nodiscc
Copy link
Member

nodiscc commented Apr 1, 2015

Fixed in bec1870 (and 3 next commits...) Thanks for your patch, sorry for the awful merge

@nodiscc nodiscc closed this as completed Apr 1, 2015
@virtualtam virtualtam modified the milestones: 0.9.0, 0.5.0 Jul 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants