Re: Trouble formatting date in ISO 8601 format
"Will Guaraldi" <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
Hrm... looks like we allow for - in variable names, so it's picking
everything up as the variable name. It also looks like we don't
support ${yr} or $(yr) names either. Though that puzzles me because I
thought I implemented something like that a while back. I don't have
time to look into it further, though--busy day.
So I threw together a plugin. It's attached. Just toss it into your
plugins directory and add "iso8601" to the plugin list.
Hope that helps--
/will
On 8/20/07, Steve Hoelzer <[email protected]> wrote:
> I want to display post dates in ISO 8601 format, like this: 2007-08-20.
>
> In my story template, I tried "$yr-$mo_num-$da", but that doesn't
> work. All I get out is the day number (20).
>
> If I put spaces around the dashes, "$yr - $mo_num - $da", it works
> fine -- except that I have spaces around the dashes in the output:
> 2007 - 08 - 20.
>
> What's going on here? Is there a way to generate the date without
> spaces around the dashes?
>
> Thanks,
> Steve
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> pyblosxom-users mailing list
> pyblosxom-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/pyblosxom-users
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
pyblosxom-users mailing list
pyblosxom-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-users
iso8601.py
(text/x-python, 742 B)
"""
Summary
=======
This plugin was thrown together to meet Steve's need for an ISO 8601
formatted date since we apparently can't do that with variables.
The variable this creates for each story is::
$iso8601date
License
=======
This plugin is placed in the public domain.
"""
__author__ = "Will Guaraldi - willg at bluesock dot org"
__version__ = "1.0"
__url__ = "none"
__description__ = "Provides a ISO 8601 format date"
import time
def cb_story(args):
req = args["request"]
entry = args["entry"]
# this adds the iso8601date to the entry in-place
entry["iso8601date"] = time.strftime("%Y-%m-%d",
time.gmtime(entry["mtime"]))
# return the args dict
return args