Intel's Ronler Acres Plant

Silicon Forest

Monday, February 12, 2018



I'm working on simple C program to experiment with pipes. All it does it take a line from the keyboard, prepend it with a time stamp and write it to a file. A call to the time() function will deliver the time. I could use it as is, it's just a big integer. It would be nice if you could format it as a calendar date and time. I'm looking at the appendix of my C programming manual and there are calls for converting time from this format and writing the time in that format, but there doesn't seem to be one that will do what I want.

    time_t time(time_t *tloc);

There are basically two ways of dealing with time. One way is to use a big integer to store the number of seconds since the beginning (which varies depending on what planet you live on) and the other is to break the time into days, months, seconds and mintues, etc. and store all these various values in a data structure.

    time_t mktime(struct tm *tp);

mktime() will take the data structure and convert it into a number of seconds, but I cannot find one that will do the conversion in the other direction. I ran into this problem umpteen years ago and spent a few days writing my own routine to perform the conversion. Now I'm reading the appendix and I'm thinking it's really weird that there isn't a function to do this. I'm hoping I'm wrong, because I don't want to have to dig out my old conversion routine because that's just more code I have to look at and think about and that's going to distract me from what I am trying to do.

    struct tm *gmtime(const time_t *tp);

So I look more closely at these routines in the book and I finally realize that they are using the same variable name tp as a pointer to the two different variables used to store the time. No wonder I couldn't figure it out last time. Couldn't they have used two different variable names, like tip for time-integer-pointer and tsp for time-structure-pointer? I guess you're supposed to read the whole declaration and not just the variable name. Bah.


Newman's Coffee
I went to Freddies yesterday to pick up some groceries. One of the items on the list was Newman Decaf Coffee pods for the Keurig coffee maker. Freddies has a whole wall of coffee in 47 flavors. I find Newman's Coffee right off. There are three kinds there, but none are decaf. I carefully look over the entire wall and notice that Starbucks takes up a good third, Dunkin Donuts has noticeable presence and there are 20 or 30 (or 40) other brands there as well, but no more Newman. I do this at least twice and finally conclude that the three boxes I spotted originally are the only Newman pods available. Now I re-read the labels again and I realize the first box is actually decaf. I can only conclude that I read the label as Special Dark instead of Special Decaf, which is what it actually says. Why would someone label decaf as special? Is there a regular decaf? Marketing is getting way out of hand.

Being able to read is fundamental to getting along in today's world, and being able to pick out minuscule differences is a useful skill to have if you are programming computers. And here I detected two failures to detect differences in two days. It might be distressing if I wasn't immune to self-criticism.

No comments: