Open2300 - Get UTC From System
You are here: Foswiki>Open2300 Web>GetUTCFromSystem (10 Feb 2014, BenLye)Edit Attach

Get UTC From System for CW2300 and WU2300

Introduction

Get UTC from system to avoid offset errors.

Description of Patch

When ever daylight savings time changes your offset with UTC, the time stamp in cw2300 and wu2300 will be off by an hour until you edit your config file. The code below is a change to the GET DATE AND TIME code section to use the function gmtime() instead of localtime().

Installation of Patch

Edit cw2300.c to change the GET DATE AND TIME code section as follows:
/* GET DATE AND TIME FOR the WX record in UTC */
time(&basictime);
//   basictime = basictime - atof(config.timezone) * 60 * 60;
//   strftime(datestring, sizeof(datestring), "@%d%H%Mz",localtime(&basictime));
/* USE gmtime TO GET UTC TIME FROM THE SYSTEM */
strftime(datestring,sizeof(datestring), "@%d%H%Mz", gmtime(&basictime));
Edit wu2300.c to change the GET DATE AND TIME code section as follows:
/* GET DATE AND TIME FOR URL */
time(&basictime);
//   basictime = basictime - atof(config.timezone) * 60 * 60;
//   strftime(datestring,sizeof(datestring),"&dateutc=%Y-%m-%d+%H%%3A%M%%3A%S",
//       localtime(&basictime));
/* USE gmtime TO GET UTC TIME FROM THE SYSTEM */
strftime(datestring,sizeof(datestring),"&dateutc=%Y-%m-%d+%H%%3A%M%%3A%S",
gmtime(&basictime));
strcat(urlline, datestring);

Then make and install:

make cw2300 wu2300

make install

Change History of Patch

version 1.0

Discussion and Comments


Edited the code snippets in the Wiki to prevent code being interpreted by FosWiki - makes cutting and pasting easier. I'm now using the modifications as well.

-- BenLye - 10 Feb 2014

I've used this code successfully on my system for over six months with no problems.
Topic revision: r2 - 10 Feb 2014, BenLye
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.