Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 15 Nov 2018, 15:42
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BusyBox "cal" command with week-start, no julian?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
torm


Joined: 07 Mar 2015
Posts: 168

PostPosted: Mon 10 Oct 2016, 06:31    Post subject:  BusyBox "cal" command with week-start, no julian?  

BusyBox built-in cal command only takes year-display/julian-dates switches.
It is to be SUSv3 compliant..

Is it possible to:
Apply something like

Code:
diff -ruNt busybox-1.19.4_orig/coreutils/cal.c busybox-1.19.4/coreutils/cal.c
--- busybox-1.19.4_orig/coreutils/cal.c   2012-02-04 20:24:55.000000000 +0100
+++ busybox-1.19.4/coreutils/cal.c   2012-02-11 01:51:33.000000000 +0100
@@ -139,7 +139,7 @@
                 month_names[i] = xstrdup(buf);
 
                 if (i < 7) {
-                        zero_tm.tm_wday = i;
+                        zero_tm.tm_wday = i + 1; /* MHHP: + 1, for Monday as first day of the week */
                         /* abbreviated weekday name according to locale */
                         strftime(buf, sizeof(buf), "%a", &zero_tm);
 #if ENABLE_UNICODE_SUPPORT
@@ -264,7 +264,7 @@
          * 3 Sep. 1752 through 13 Sep. 1752.  Returns Thursday for all
          * missing days.
          */
-        temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1) + day;
+        temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1) + day - 1; /* MHHP: - 1, for Monday as first day of the week */
         if (temp < FIRST_MISSING_DAY) {
                 dw = ((temp - 1 + SATURDAY) % 7);
         } else {

patch to BB cal source,
(to support week-start day=monday/sunday)
remove julian-dates support,
preserve local language support ( for month and week-day names ) ,
make a package that could be compiled (with most Puppys) as a tiny standalone binary,
maybe name it something different than "cal"..

PS.
Standard util-linux-2.28 cal makes a 42k size binary ( stripped ) .
Patched BB cal ( without language support ) around 10k,
as I have no idea how to compile it without BB.. ( see BB TODO notes in source )
There is a bash way around it, like so:
http://unix.stackexchange.com/questions/29434/displaying-weeks-number-in-certain-format-using-ncal-or-cal
is that a reliable alternative? Or is the licensing ( CC-BY-SA 3.0 ) acceptable?
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 168

PostPosted: Mon 20 Aug 2018, 03:35    Post subject:  

Modified a little the color-cal version 4.0

ChangeLog:
- renamed to "kale" to avoid confusion
- locale support enabled by default
- added automated week-start-day (Sunday/Monday) detection
- added support for locales that have single glyph abbr. weekday names
- removed all terminal color "whistles" and .. just about everything that
is outside single month calendar.
Makes a pretty small executable, less than 10kb on my system..

Notes.
kale takes no commandline options, comments or switches - only displays the
current month calendar with "today" marked ( see screenshot ) nothing else.
That would be mostly all that is needed for Conky, GKrellm2 and alike, for
piped input.
In GUI apps, try using fixed fonts Wink
To output the calendar to a file, type in terminal for example:
kale > /root/mycalendarfile


License.
kale is placed into the Public Domain.
kale.c has the initial MIT-style license at the top - as it was in the original cal.c file.
From original readme.cal file:
This archived collection of files is placed into the Public Domain.


Build and install.
There is only the C source package.
Default install path is /root/my-applications/bin, to change that - edit Makefile.
Should build on most Puppy versions without any specific dependencies, just type:

make
make install

___

This is the first version of kale, so it may have some unused or unfinished features,
please report any bugs found.
TODO: fine-tuning, cleanup and testing for different locales.
All suggestions are welcome.
kale_C_source-00.tar.gz
Description  C source
gz

 Download 
Filename  kale_C_source-00.tar.gz 
Filesize  3.99 KB 
Downloaded  20 Time(s) 
kale-screenshot-00_with-different-locales.png
 Description   screenshots with different locales
 Filesize   12.25 KB
 Viewed   72 Time(s)

kale-screenshot-00_with-different-locales.png

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0506s ][ Queries: 12 (0.0091s) ][ GZIP on ]