Trouble with timezone()
Hi, I'm trying to convert the time information in messages so they match the timezone offset of a remote device. Initially I was using time_zone(). This seemed to work ok until I tried and offset of greater than 12hours, which failed. It occurred to me that this utility is intended convert messages initially with GMT time to a GMT +/- offset time hence only +/-12 is required. What I want to be able to do is make a coversion relative to local time, so I need to be able to handle an offset of up 23 hours. I'm trying to use timezone(), which is supposed to take an offset value in seconds. However I can't work out the syntax. For a 2 hour offset I've tried: timezone(7200) timezone("7200") timezone("+7200") timezone(+7200) For each of these I get config parsing errors. Can anyone help me out please? Anthony
On Thu, 2006-12-07 at 15:09 +1300, anthony lineham wrote:
Hi,
I'm trying to convert the time information in messages so they match the timezone offset of a remote device. Initially I was using time_zone(). This seemed to work ok until I tried and offset of greater than 12hours, which failed. It occurred to me that this utility is intended convert messages initially with GMT time to a GMT +/- offset time hence only +/-12 is required.
What I want to be able to do is make a coversion relative to local time, so I need to be able to handle an offset of up 23 hours. I'm trying to use timezone(), which is supposed to take an offset value in seconds. However I can't work out the syntax. For a 2 hour offset I've tried: timezone(7200) timezone("7200") timezone("+7200") timezone(+7200)
For each of these I get config parsing errors.
The format of the time_zone argument is [+/-]HH:MM, where did you read about seconds? I'd like to fix it if you found this in the documentation. -- Bazsi
I saw it in the html documentation that came with 2.0rc3, in Table 3.6. Common options for destination drivers. Here is the text: timezone() timezone offset in seconds unspecified Convert timestamps to a different timezone as specified by this option. If this option is not specified then the original timezone information in the message is used. Is the name of the option also incorrect? I noticed you referred to "time_zone" rather than "timezone". Both are present in the documentation that I have. Also can you suggest how I can deal with a time offset of greater than +/- 12 hours? Thanks Anthony
Balazs Scheidler <bazsi@balabit.hu> 7/12/2006 9:18 p.m. >>> On Thu, 2006-12-07 at 15:09 +1300, anthony lineham wrote: Hi,
I'm trying to convert the time information in messages so they match the timezone offset of a remote device. Initially I was using time_zone(). This seemed to work ok until I tried and offset of greater than 12hours, which failed. It occurred to me that this utility is intended convert messages initially with GMT time to a GMT +/- offset time hence only +/-12 is required.
What I want to be able to do is make a coversion relative to local time, so I need to be able to handle an offset of up 23 hours. I'm trying to use timezone(), which is supposed to take an offset value in seconds. However I can't work out the syntax. For a 2 hour offset I've tried: timezone(7200) timezone("7200") timezone("+7200") timezone(+7200)
For each of these I get config parsing errors.
The format of the time_zone argument is [+/-]HH:MM, where did you read about seconds? I'd like to fix it if you found this in the documentation. -- Bazsi _______________________________________________ syslog-ng maillist - syslog-ng@lists.balabit.hu https://lists.balabit.hu/mailman/listinfo/syslog-ng Frequently asked questions at http://www.campin.net/syslog-ng/faq.html
On Fri, 2006-12-08 at 08:58 +1300, anthony lineham wrote:
I saw it in the html documentation that came with 2.0rc3, in Table 3.6. Common options for destination drivers. Here is the text: timezone() timezone offset in seconds unspecified Convert timestamps to a different timezone as specified by this option. If this option is not specified then the original timezone information in the message is used.
Is the name of the option also incorrect? I noticed you referred to "time_zone" rather than "timezone". Both are present in the documentation that I have.
This is a docbug, a global option named timezone() does not exist (anymore). You either need to use source_time_zone(), dest_time_zone() settings. If I remember correctly, there was a timezone related fix after 2.0.0 was released, so you should be using the latest snapshot. I really ought to do a release soon. The 12 hours limitation in timezone offsets also seem to be a bug, the patch below fixes it. Tomorrow's snapshot should include both the patch below, and the updated docs. --- orig/src/cfg.c +++ mod/src/cfg.c @@ -52,13 +52,12 @@ cfg_timezone_value(gchar *tz, glong *tim hours = (*tz - '0') * 10 + *(tz+1) - '0'; mins = (*(tz+3) - '0') * 10 + *(tz+4) - '0'; - if (hours <= 12 && mins <= 60) + if ((hours < 24 && mins <= 60) || (hours == 24 && mins == 0)) { *timezone = sign * (hours * 3600 + mins * 60); - return TRUE; } } - msg_error("Bogus timezone spec, must be in the format [+-]HH:MM", + msg_error("Bogus timezone spec, must be in the format [+-]HH:MM, offset must be less than 24:00", evt_tag_str("value", tz), NULL); return FALSE; -- Bazsi
Thanks for the patch. I downloaded the latest snapshot and it now accepts values greater than 12 hours. However, there seems to be a new bug introduced. I now get an error message logged regardless of the time offset I enter. eg 2006 Dec 11 09:09:23 syslog.err syslog-ng[67]: Bogus timezone spec, must be in the format [+-]HH:MM, offset must be less than 24:00; value=\'05:00\' This seems to be due to the removal of the return TRUE in the patch and latest snapshot - if (hours <= 12 && mins <= 60) + if ((hours < 24 && mins <= 60) || (hours == 24 && mins == 0)) { *timezone = sign * (hours * 3600 + mins * 60); - return TRUE; } Regards Anthony
Balazs Scheidler <bazsi@balabit.hu> 12/08/06 9:40 PM >>> On Fri, 2006- 12- 08 at 08:58 +1300, anthony lineham wrote: I saw it in the html documentation that came with 2.0rc3, in Table 3.6. Common options for destination drivers. Here is the text: timezone() timezone offset in seconds unspecified Convert timestamps to a different timezone as specified by this option. If this option is not specified then the original timezone information in the message is used.
Is the name of the option also incorrect? I noticed you referred to "time_zone" rather than "timezone". Both are present in the documentation that I have.
This is a docbug, a global option named timezone() does not exist (anymore). You either need to use source_time_zone(), dest_time_zone() settings. If I remember correctly, there was a timezone related fix after 2.0.0 was released, so you should be using the latest snapshot. I really ought to do a release soon. The 12 hours limitation in timezone offsets also seem to be a bug, the patch below fixes it. Tomorrow's snapshot should include both the patch below, and the updated docs. --- orig/src/cfg.c +++ mod/src/cfg.c @@ - 52,13 +52,12 @@ cfg_timezone_value(gchar *tz, glong *tim hours = (*tz - '0') * 10 + *(tz+1) - '0'; mins = (*(tz+3) - '0') * 10 + *(tz+4) - '0'; - if (hours <= 12 && mins <= 60) + if ((hours < 24 && mins <= 60) || (hours == 24 && mins == 0)) { *timezone = sign * (hours * 3600 + mins * 60); - return TRUE; } } - msg_error("Bogus timezone spec, must be in the format [+- ]HH:MM", + msg_error("Bogus timezone spec, must be in the format [+- ]HH:MM, offset must be less than 24:00", evt_tag_str("value", tz), NULL); return FALSE; -- Bazsi _______________________________________________ syslog- ng maillist - syslog- ng@lists.balabit.hu https://lists.balabit.hu/mailman/listinfo/syslog- ng Frequently asked questions at http://www.campin.net/syslog- ng/faq.html
On Mon, 2006-12-11 at 09:18 +1300, anthony lineham wrote:
Thanks for the patch. I downloaded the latest snapshot and it now accepts values greater than 12 hours. However, there seems to be a new bug introduced. I now get an error message logged regardless of the time offset I enter. eg 2006 Dec 11 09:09:23 syslog.err syslog-ng[67]: Bogus timezone spec, must be in the format [+-]HH:MM, offset must be less than 24:00; value=\'05:00\'
This seems to be due to the removal of the return TRUE in the patch and latest snapshot - if (hours <= 12 && mins <= 60) + if ((hours < 24 && mins <= 60) || (hours == 24 && mins == 0)) { *timezone = sign * (hours * 3600 + mins * 60); - return TRUE; }
Oops, sorry. You are right, I have removed the return TRUE statement by accident. I've committed a fix. -- Bazsi
participants (2)
-
anthony lineham
-
Balazs Scheidler