Stefano Rivera wrote:
> Hi Rachael (2007.04.03_23:54:13_+0200)
>
>> I have this planet in http://www.planetgeek.org/
and regardless the
>> (Linux) server is set with the current right time,
in the right panel,
>> the time of the last update is one hour behind.
>>
>
> Planet shows time in UTC, not local time.
>
>
>> Does anyone knows how to fix this ?
>>
>
> No one seems to have written anything that does that,
yet.
>
> I'd also appreciate something like that for our local
planets in ZA
> (UTC+2)
>
> SR
A user made a rudimentary patch long ago. [1] From that, I
added some
code so that you can specify a UTC offset from the
config.ini file. It's
certainly not the cleanest code you'll ever run across, but
I've been
using this just fine with Planet 2.0:
First, in planet.py, somewhere before this line:
> # Default template file list
add this line:
> TIME_OFFSET = 0 # from UTC in hours
This sets the default offset, in case config.ini doesn't
specify one.
Then, after this line:
> feed_timeout = config_get(config, "Planet",
"feed_timeout",
> FEED_TIMEOUT)
add this line:
> time_offset = int(config_get(config,
"Planet", "time_offset",
> TIME_OFFSET))
This attempts to read in a time offset from config.ini, but
can fall
back on the default if necessary. Then, change these lines:
> my_planet.generate_all_files(template_files,
planet_name,
> planet_link, planet_feed, owner_name,
owner_email)
to read:
> my_planet.generate_all_files(template_files,
planet_name,
> planet_link, planet_feed, owner_name,
owner_email,
> time_offset)
Now, in planet/__init__.py, change this line:
> def gather_items_info(self, channels,
template_file="Planet",
> channel_list=None):
to read:
> def gather_items_info(self, channels, time_offset,
> template_file="Planet", channel_list=None):
After these lines:
> for newsitem in
self.items(max_items=items_per_page,
>
max_days=days_per_page,
>
channels=channel_list):
add this line:
> newsitem.date =
time.localtime(time.mktime(newsitem.date)
> + time_offset * 3600)
Change these lines:
> if prev_date[:3] != newsitem.date[:3]:
> prev_date = newsitem.date
> item_info["new_date"] =
time.strftime(new_date_format,
>
newsitem.date)
to read:
> if prev_date[:3] !=
> time.localtime(time.mktime(newsitem.date) + time_offset
* 3600)[:3]:
> prev_date =
time.localtime(time.mktime(newsitem.date)
> + time_offset * 3600)
> item_info["new_date"] =
time.strftime(new_date_format,
>
> time.localtime(time.mktime(newsitem.date) + time_offset
* 3600))
Change these lines:
> def generate_all_files(self, template_files,
planet_name,
> planet_link, planet_feed, owner_name,
owner_email):
to read:
> def generate_all_files(self, template_files,
planet_name,
> planet_link, planet_feed, owner_name,
owner_email,
> time_offset):
Change this line:
> items_list =
self.gather_items_info(channels, template_file)
to read:
> items_list =
self.gather_items_info(channels, time_offset,
> template_file)
Finally, change this line:
> date = time.gmtime()
to read:
> date = time.localtime(time.time() + 3600)
Hope that helps.
[1] http://lists.planetplanet.org/archives/devel/
2005-March/000441.html
--
Minh Nguyen <mxn zoomtown.com>
AIM: trycom2000; Jabber: mxn myjabber.net; Blog: http://mxn.f2o.org/
--
devel mailing list
devel lists.planetplanet.org
http://lists.planetplanet.org/mailman/listinfo/devel
|