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 Mon 22 Apr 2019, 14:46
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
cal command alternatives
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 3 [45 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
rufwoof

Joined: 24 Feb 2014
Posts: 3014

PostPosted: Sat 01 Dec 2018, 09:14    Post subject:  

MochiMoppel wrote:
@ rufwoof: cal chokes on $1 $2. Works when I place IFS='|' after the cal commands

Thanks. That IFS setting is unneccessary so I've edit that post to just IFS=

_________________
( ͡° ͜ʖ ͡°) :wq
Back to top
View user's profile Send private message 
rufwoof

Joined: 24 Feb 2014
Posts: 3014

PostPosted: Sat 01 Dec 2018, 09:17    Post subject:  

musher0 wrote:
Finally, perhaps I'm way off, but shouldn't there be a mention of calcurse
on this thread?

I do mostly use calcurse myself, but also don't forget osmo

_________________
( ͡° ͜ʖ ͡°) :wq
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13920
Location: Gatineau (Qc), Canada

PostPosted: Sat 01 Dec 2018, 10:15    Post subject:  

Osmo? Yerk! Twisted Evil
_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1823
Location: Japan

PostPosted: Sat 01 Dec 2018, 10:27    Post subject:  

Here is my attempt. Not better than anything presented so far, hopefully not much worse. I tried to implement the idea to cut the first column, add it to the right and then shift it one notch up.
It can easily be made portable (executable with busybox ash) by redirecting SUND and REST to temp files and then reading these files with paste. I just don't like tmp files Crying or Very sad
Code:
 #!/bin/bash
## Usage: scriptname [month [year]]
## Defaults to current month year if no parameters passed
MNTH=${1:-$(date +%m)}
YEAR=${2:-$(date +%Y)}
CLDR=$(cal $MNTH $YEAR)
BODY=$(echo "$CLDR" | tail +3)
HEAD=$(echo "$CLDR" | head -2 | sed -r '2s/(...)(.*)/\2 \1/')
EMTY='                     '
BODY=$EMTY$'\n'$BODY
BODY=$(echo "$BODY" | sed  -r "s/.*/&$EMTY/ ; s/(.{21}).*/\1/")
SUND=$(echo "$BODY" | grep -o ^... | tail +2)
REST=$(echo "$BODY" | grep -o ..................$)
BODY=$(paste -d '' <(echo -n "$REST" ) <(echo -n "$SUND" )  )
BODY=$(echo "$BODY" | sed -r "s/ *$//; /^ *$/d")
echo "$HEAD"$'\n'"$BODY"
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13920
Location: Gatineau (Qc), Canada

PostPosted: Sat 01 Dec 2018, 10:53    Post subject:  

Hi MM.

Thanks.

The script name is... ?

Right up my alley, too. I love gory variable names, such as Body, Head.
Plus you're inflicting all sorts of operations on them. Miam.
(Blame that dark humor on the Kashoggi affair...)

Never mind the script name. I decided to call it "gory-cal.sh" Twisted Evil

BFN.

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
rufwoof

Joined: 24 Feb 2014
Posts: 3014

PostPosted: Sat 01 Dec 2018, 12:06    Post subject:  

Very nice!
_________________
( ͡° ͜ʖ ͡°) :wq
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 179

PostPosted: Thu 06 Dec 2018, 11:10    Post subject:  

MochiMoppel wrote:
torm wrote:
util-linux cal command output on the screenshot is correct for my locale, while
the BusyBox output is "somewhat strange", if you look at the details..
And what is your locale?
If busybox cal fails to display weekday abbreviations then I would consider this to be a serious bug. Would make no sense to start any reformatting acrobatic before this issue is solved.

On the other hand I have found no other reports regarding this issue. Strange indeed.


et_EE
Weekday abbreviations appear to be broken in tahrpup32bit606 and 64bit605 while 32bit605 is ok, no idea..
Other calendar programs/commands work fine, and for now I just skip anything BusyBox cal related.
Well.. until I have a solid fix for it.
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 179

PostPosted: Thu 06 Dec 2018, 11:15    Post subject:  

ncal

ncal is a small ( around 20-30 kb size ) FreeBSD alternative to cal command.
It should be possible to extract official version of ncal from bsdmainutils package.
ncal is released under MIT-style license.

ncal supports:
-full year view
-horizontal and vertical weeks layout
-week-start-day from current locale or by option
-julian dates
-3 months view
-years 1 to 9999
-month selection by number ( 1 - 12 ) or month name in the current locale
-... and then some more stuff, like Easter date, etc.

dependencies:
libtinfo.so.5 ( ncurses ) is most likely pre-installed in puppy.

Official source turned out to be a bit "unusual" , so I made a more compact and
stand-alone source package for it, to simplify compile and install.
Think of it as TEST source at this point.
There is manpage and a small README included, read them when in doupt.

Should compile and install with:
make
make install

To run ncal with the usual cal layout, type:
ncal -b

To view manual page for more options, type:
man ncal


Edit:
Added below some precompiled versions of ncal from official Ubuntu pakages.
These include ncal, man page and copyright notice.
ncal__trusty-32bit.pet
Description  ncal for 32-bit tahrpup
pet

 Download 
Filename  ncal__trusty-32bit.pet 
Filesize  15.83 KB 
Downloaded  45 Time(s) 
ncal__trusty-64bit.pet
Description  ncal for 64-bit tahrpup
pet

 Download 
Filename  ncal__trusty-64bit.pet 
Filesize  16.62 KB 
Downloaded  40 Time(s) 
ncal__xenial-64bit.pet
Description  ncal for 64-bit xenialpup
pet

 Download 
Filename  ncal__xenial-64bit.pet 
Filesize  16.94 KB 
Downloaded  43 Time(s) 
ncal_C-source_01.tar.gz
Description  ncal C source and user manual
gz

 Download 
Filename  ncal_C-source_01.tar.gz 
Filesize  22.48 KB 
Downloaded  48 Time(s) 
ncal_different_layouts.jpg
 Description   ncal with different layouts
 Filesize   55.68 KB
 Viewed   435 Time(s)

ncal_different_layouts.jpg


Last edited by torm on Fri 14 Dec 2018, 17:30; edited 1 time in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1823
Location: Japan

PostPosted: Fri 07 Dec 2018, 05:17    Post subject:  

torm wrote:
Other calendar programs/commands work fine, and for now I just skip anything BusyBox cal related.
I noticed that in your list of cal alternatives you didn't mention dialog, with layout very similar to cal and - as a CLI application - pretty lightweight. Unlike cal it's interactive.
Code:
#!/bin/bash
OUTPUT=$(dialog --stdout --calendar "" 0 0 15 8 2018)
clear
echo "You selected: $OUTPUT"
dialog--calendar.png
 Description   
 Filesize   6.13 KB
 Viewed   394 Time(s)

dialog--calendar.png

Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13920
Location: Gatineau (Qc), Canada

PostPosted: Fri 07 Dec 2018, 06:34    Post subject:  

Torm did not mention it because it is ugly!... Twisted Evil (IMO)
_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 179

PostPosted: Sun 09 Dec 2018, 10:37    Post subject:  

How to set the correct week-start-day in dialog ( cdialog ) ?
By patching the preinstalled binary in puppy .. ?

PS.
It is not about how it looks - that would be a matter of settings.
Type:
dialog --create-rc /root/.dialogrc
..and edit that file. Wink
dialog_calendar.jpg
 Description   dialog_screenshot
 Filesize   69.85 KB
 Viewed   323 Time(s)

dialog_calendar.jpg

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1823
Location: Japan

PostPosted: Thu 20 Dec 2018, 01:50    Post subject:  

torm wrote:
How to set the correct week-start-day in dialog ( cdialog ) ?
By patching the preinstalled binary in puppy .. ?
Good idea Laughing

As for your troubled busybox cal I can't confirm your problem with locale et_EE.
Apart from the "incorrect" week-start-day it looks OK to me. Using busybox v1.21.0
cal_et_EE.png
 Description   
 Filesize   7.51 KB
 Viewed   271 Time(s)

cal_et_EE.png

Back to top
View user's profile Send private message 
mfb

Joined: 22 Mar 2016
Posts: 71

PostPosted: Thu 20 Dec 2018, 16:51    Post subject:  

I was seeking a year@view calendar to show Bank Holidays (meaning Public Holidays) in England & Wales which are:

In January - the 1st day, but If this falls on a Saturday or Sunday, the Pubic Holiday is the following Monday

In March or April - Good Friday and Easter Monday

In May - the first and last Mondays

In August - the last Monday

In December - the 25th and 26th, but if the 25th falls on a Saturday the Public Holidays are the following Monday and Tuesday or if the 25th falls on a Sunday then the following Tuesday is a Public Holiday.

Thanks to Burunduk for his script here http://murga-linux.com/puppy/viewtopic.php?p=1013199&sid=a9bcdb7550e1be68a6ba2cd94b6fa2b4#1013199 which I named “y” and after a few minor changes to the days, columns and colours displays for “y 2019“ as in the image below.

Thanks also to torm for his advices on “ncal” so, when installed, “ncal -e” yields Easter Sunday in the current year, or for another year with the addition of “ yyyy” as shown at the foot of the image.

Whilst at least one and at most three Bank Holidays are actually highlighted, they are all easily seen using “y yyyy” then “ncal -e yyyy”.
-----------------------------------
Special thanks extend to MochiMoppel and puppy_apprentice for their contributions and guidance.
image.jpg
 Description   
 Filesize   121.32 KB
 Viewed   289 Time(s)

image.jpg

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1823
Location: Japan

PostPosted: Fri 21 Dec 2018, 08:42    Post subject:  

mfb wrote:
the Pubic Holiday is the following Monday
Shocked celebrating what?
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2647

PostPosted: Fri 21 Dec 2018, 13:13    Post subject:  

In Mexico, people celebrate their own birthday, but also the day of the Saint they are named after. When someone doesn't show up to wrok on Monday, they say one is celebrating San Lunes (Saint Monday).
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [45 Posts]   Goto page: Previous 1, 2, 3 Next
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.0539s ][ Queries: 13 (0.0080s) ][ GZIP on ]