Monday, February 6, 2012

Bad Dates

So the new jffs base is barely out for a day and the bug reports are already rolling in.  I included a tiny cal program as a freebie, mostly so I could tinker with the ansi escape menu code on the jffs.  But apparently it prints out bogus calendars, and doesn't even support the vital -m switch to start the metric week off properly on a Monday!  We can't have that.

Actually I was just starting to pull together the various bits needed for the alarm clock portions of my planned internet clock radio package when dronz filed his bug report.  So I suppose I should probably attempt to fix the calendar first. Darn it!  I took a longer look at the code and discovered some obvious problems.  I'm pretty sure January usually has 31 days, not 21.  Even after that fix all the days were still off by 1.  Was time counted differently way back before y2k when this code was probably written?  I can't remember, so maybe it was.

Anyhow, I hacked in the -m setting and fixed enough math errors to get past the end of 2012.  According to the Mayans, the world's supposed to end in 2012 so that's probably good enough.  Right?
Meanwhile I'd really like to get a nice alarm clock running on the zipit before then.  I built a smaller shared lib version of the tty-clock executable from IZ2S.  It's ok for a start, but I'd prefer something really sharp like the retro flipclock they've got on the maemo.  The source is mostly SDL, with a tiny helping of gtk for the alarm sound file selector dialog.  Fortunately the ben nanonote has a tiny fileselector program from the jlime distro that's written in SDL and could work as a replacement for the gtk.  It took a while to get it working because of the uclibc dirclose() segfault that I worked around for sdlbasic, and then promptly forgot about.  It's still there in the IZ2S uclibc though, so I'm sure it'll get me again.  
 The jlime fileselector works pretty well now in IZ2S, but it's a bit large for the jffs because it requires a truetype font and all the bloatware that goes along with that.  I did some searching and discovered the SamyGo folks may have written an SDL_ttf replacement that uses a tiny linux console font instead of truetype fonts.  I couldn't locate the code but I may make a go of that myself, especially with all my recent console font file experience.  I also noticed gnurobbo has a compiler setting to use pixmap fonts instead of SDL_tty, so I might just take a peek at that as well.

If I do manage to produce a substitute lib using the console font I'll probably try to build a mini version of the dgClock program from a previous blog post.  It weighs in at only 18K if I can ditch the 1MB required for SDL_ttf and libfreetype.  It's also quite a bit prettier than the cal program, but I don't know if it has a setting to display the metric version of the calendar.

Here's an updated cal program, with source code so you can fix the math yourself in 2013, if that ever happens.

Here's the smaller shared lib ttyclock executable and a few alarm scripts to cull for ideas.


  1. Setting your timezone with automatic daylight saving changes is just adding a line to Zcovery:

    1. Nice tip. My timezone setting script is really only a hint. I'd already switched to EST5EDT myself, but didn't have a good source of info for other zones.

      Does it need to be in Zcovery, or can you just do it once, redirecting into /mnt/ffs/etc/TZ (or /mnt/sd0/etc/TZ for IZ2S)?

  2. I think (but not sure) it must be in Zcovery to create the appropriate /etc/TZ at each boot.

    1. Oops! Just create a TZ file with the appropriate line from the page,
      and copy it to /mnt/ffs/etc/ , Zcovery does the symlink to /etc/ !
      I thought it didn't work because IZ2S205beta-enhanced-020410's (and Zcovery) have a typo at symlinking /usr/local/etc/ .