TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: NOTREAL
from: THE NATURAL PHILOSOPHER
date: 2018-09-25 09:36:00
subject: Re: Formatting for UTC Da

On 24/09/18 16:01, NotReal wrote:
> The Natural Philosopher wrote:
>
>> On 23/09/18 21:17, NotReal wrote:
>>> I am in need of some assistance in configuring the time display on
>>> “sunclock: version 3.56, J.-P. Demailly”.  After fiddling around with
>>> the .rcfile, I have managed to configure the local time (EDT) and date
>>> in the lower left corner of the display and the UTC date and time on
>>> the lower right -- well almost.  The date that is supposed to be UTC
>>> remains as the local date.    The result is that the date is wrong
>>> between 20:00 and 24:00 local each day.    I have found the UTC
>>> switches for UTC hour (%G) and minutes (%N) but I cannot find what I
>>> should use for UTC day of the week, day, month, and year.    I have a
>>> feeling there are no such switches, but it doesn’t hurt to ask.
>>>
>>
>> This is all there is (function writeStrip in sunclock.c)
>>
>> I suggest you add some code to this section and recompile
>>
>>
>> ##############################################
>>                         case 'G': sprintf(num, "%02d", gtp.tm_hour);
break;   
>>                          case 'H': sprintf(num, "%02d", ltp.tm_hour); break;
>>                          case 'M': sprintf(num, "%02d", ltp.tm_min); break;
>>                         case 'N': sprintf(num, "%02d", gtp.tm_min);
break;   
>>                          case 'P': num[0]=ampm; num[1]='\0'; break;
>>                          case 'S': sprintf(num, "%02d", ltp.tm_sec); break;
>> #ifdef NEW_CTIME
>>                          case 'Z': strcpy(num, ltp.tm_zone); break;
>> #else
>>                          case 'Z': strcpy(num, tzname[ltp.tm_isdst]); break;
>> #endif
>>                         case 'a': strcpy(num, Day_name[ltp.tm_wday]); break;
>>                          case 'd': sprintf(num, "%02d", ltp.tm_mday); break;
>>                          case 'h': sprintf(num, "%02d", hour); break;   
>>                         case 'j': sprintf(num, "%02d", 1+ltp.tm_yday);
break;
>>                         case 'b': strcpy(num, Month_name[ltp.tm_mon]);
break;
>>                         case 'm': sprintf(num, "%02d", 1+ltp.tm_mon); break;
>>                          case 't': {
>>                             int w = ltp.tm_year+1900;
>>                             if (w % 4==0 && (w % 100!=0 || w % 400 == 0))
>>                               w = 366;
>>                             else
>>                               w = 365;
>>                             sprintf(num, "%d", w);
>>                             break;
>>                             }
>>                         case 'y': sprintf(num, "%02d", ltp.tm_year%100);
break;
>>                         case 'Y': sprintf(num, "%d", ltp.tm_year+1900);
break;
>>                          case 'U': {
>>                             struct tm ftm;
>>                             time_t ftime;
>>                             int w;
>>                             /*
>>                              * define weeknumber
>>                              * week #1 = week with the first thursday
>>                              */
>>                            /* set reference date to 1st of january, 12:00:00
*/
>>                             (void) memset(&ftm, 0, sizeof(struct tm));
>>                             ftm.tm_isdst = -1;
>>                             ftm.tm_mon = 0;
>>                             ftm.tm_mday = 1;
>>                             ftm.tm_year = ltp.tm_year;
>>                             ftm.tm_hour = 12;
>>                             ftm.tm_min = 0;
>>                             ftm.tm_sec = 0;
>>                             ftime = mktime(&ftm);
>>                             ftm = *localtime(&ftime);
>>                             /* get first sunday (start of week) */
>>                             if (ftm.tm_wday < 5)
>>                                w = 1 - ftm.tm_wday;
>>                             else
>>                                w = 8 - ftm.tm_wday;
>>                             /* get weeknumber */
>>                             sprintf(num, "%02d",
>>                                  ((ltp.tm_yday+1-ltp.tm_wday-w)/7)+1);
>>                             break;
>>                             }
>>                          case '_': c = ' ';
>>                          default: num[0] = c; num[1] = '\0'; break;
>
>
> That was a noble idea.  I added the following lines to sunclock.c after
“case
> 'Y'” at line 2048.
>
>
> /*
>   * Begin Add for UTC Week
> */
>                 case 'f': strcpy(num, Day_name[gtp.tm_wday]); break;
>                 case 'e': sprintf(num, "%02d", gtp.tm_mday); break;
>                 case 'k': sprintf(num, "%02d", 1+gtp.tm_yday); break;
>                 case 'c': strcpy(num, Month_name[gtp.tm_mon]); break;
>                 case 'n': sprintf(num, "%02d", 1+gtp.tm_mon); break;
>                 case 'v': {
>                    int w = gtp.tm_year+1900;
>                    if (w % 4==0 && (w % 100!=0 || w % 400 == 0))
>                      w = 366;
>                    else
>                      w = 365;
>                    sprintf(num, "%d", w);
>                    break;
>                    }
>                 case 'w': sprintf(num, "%02d", gtp.tm_year%100); break;
>                 case 'W': sprintf(num, "%d", gtp.tm_year+1900); break;
>
> /*
>   * End Add for UTC Week
> */
>
> I figured that was enough to at least try but that is where the experiment
> ended.  Let me first preface this by stating that although I have been a
> Slackware user for many years, this is my first foray into Raspian.  When I
> went to compile after the additions, I was expecting to do “./configure”,
> “make”, and “make install”, but after reading the INSTALL file I knew
that was
> not going to happen.  I first tried “xmkmf “, but that resulted in
“command not
> found”.
>
> I next tried. “make -f Makefile.noimake “ but that immediately resulted
in
> “fatal error: X11/Xatom.h: No such file or directory”.   A search for
> “Xatom.h.” showed that it was more than a path problem.  It just wasn’t
there
> on the Pi.
>
> A search on my Slackware server however showed that it did have an
“Xatom.h”
> file so I tried to do a compile on that using “make -f Makefile.noimake”.
 It
> apparently then found the “Xatom.h” file but it also produced tons of new
> warnings and errors until it finally bombed out.  I tried it with both the
> unmodified and modified versions of sunclock.c, so it is not just my
tinkering
> that was the problem, although I have to admit there were a few more errors
in
> the modified version.
>
> Based on my level of expertise, as in a lack of, I think I am done on this
> effort.
>
> Thanks for trying.
>
>
https://wiki.debian.org/Packaging/SourcePackage

Download the source pakage and proceed as indicated. It should 'just build'

You need to be root probly to build stuff

Then make the changes and try again.


--
Microsoft : the best reason to go to Linux that ever existed.

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.