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

Formatting media.datetime #271

Closed
nelsonov opened this issue Nov 13, 2017 · 2 comments
Closed

Formatting media.datetime #271

nelsonov opened this issue Nov 13, 2017 · 2 comments
Milestone

Comments

@nelsonov
Copy link

In the documentation for themes, you mention formatting datetime like this:
{% if media.exif.datetime %}
{{ media.exif.datetime.strftime('%A, %d. %B %Y') }}
{% endif %}

However, media.exif.datetime does not appear to be a Python datetime object. When I attempt this in the colorbox index.html, I get the following error
File "/media/cams/themes/colorbox/templates/index.html", line 44, in template
data-date=", {{ media.exif.datetime.strftime('%c') }}"
jinja2.exceptions.UndefinedError: 'unicode object' has no attribute 'strftime'

Am I missing something?

Thank you.

@saimn
Copy link
Owner

saimn commented Nov 14, 2017

The documentation is wrong (sorry!), datetime is indeed a formatted string (with strftime('%A, %d. %B %Y')), but there is also a dateobj key with the Python datetime object:
https://github.com/saimn/sigal/blob/master/sigal/image.py#L303-L316
Can you check if it works for you ? (And if you want to fix it, you're welcome 😉 )

nelsonov added a commit to nelsonov/sigal that referenced this issue Nov 26, 2017
As discussed in Issue saimn#271

In the documentation media.dateobj was mistakenly called
media.datetime while media.datetime itself is a string.

Added some more media date related values.  To avoid breaking things,
dateobj and datetime remain unchanged.  datetimelocal, datelocal and
timelocal were added.  As their names imply, they contain values
appropriate for the system's LOCALE.
@saimn saimn closed this as completed in 1e96a7c Jan 3, 2018
@saimn
Copy link
Owner

saimn commented Jan 3, 2018

I added a datetime_format setting in 1e96a7c

@saimn saimn added this to the 1.4 milestone Jan 3, 2018
kontza pushed a commit to kontza/sigal that referenced this issue Aug 28, 2020
- The default format is now `%c`
- Fix documentation confusion between ``datetime`` and ``dateobj``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants