List Info

Thread: Set time




Set time
user name
2007-04-03 16:54:13
Hi,

A week ago the time in Portugal was set to an hour ahead.

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.

Does anyone knows how to fix this ?

Any help would be appreciated.

Regards,
Rachael
-- 
devel mailing list
devellists.planetplanet.org

http://lists.planetplanet.org/mailman/listinfo/devel

Re: Set time
user name
2007-04-04 01:45:04
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

-- 
Stefano Rivera
  http://rivera.za.net/
  H: +27 21 794 7937   C: +27 72 419 8559
-- 
devel mailing list
devellists.planetplanet.org

http://lists.planetplanet.org/mailman/listinfo/devel

Re: Set time
country flaguser name
United States
2007-04-04 03:08:21
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 <mxnzoomtown.com>
AIM: trycom2000; Jabber: mxnmyjabber.net; Blog: http://mxn.f2o.org/


-- 
devel mailing list
devellists.planetplanet.org

http://lists.planetplanet.org/mailman/listinfo/devel

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )