├── BUGS.md ├── COPYING ├── MANIFEST ├── README.md ├── TODO.md ├── bin ├── PLCAL_README.md ├── README.md ├── cal ├── dcal ├── lcal ├── pc ├── plcal └── rcal ├── dev ├── README.md ├── css │ ├── README.md │ ├── default.css │ └── template.css ├── discordian │ ├── README.md │ ├── dcal │ ├── gd_conversion.sh │ └── gdj_conversion.sh ├── hebrew │ ├── TODO.md │ ├── hcal │ └── hebrew.rb ├── lcal-python │ ├── CalendarData.py │ └── README.md ├── locale │ ├── README.md │ └── get_locale ├── perpetual-scripts │ ├── README.md │ ├── arrays │ ├── leap-cycle.txt │ ├── leap.sh │ ├── matrix │ ├── non-leap-cycle.txt │ ├── non-leap.sh │ ├── perpetual-strings.txt │ └── string-matrix ├── reformation │ ├── README.md │ ├── lcal.dev │ └── sept1752 └── shcal ├── docs ├── documentation.md ├── lcal-doc.html ├── lcal.1.html └── plcal.1.html ├── man ├── install_man ├── lcal.1 ├── plcal.1 └── showman.sh ├── perl └── modules │ └── Stardate │ ├── Changes │ ├── MANIFEST │ ├── Makefile.PL │ ├── README │ ├── bin │ ├── monthly.sh │ └── stardate.pl │ ├── lib │ └── Stardate.pm │ └── t │ └── Stardate.t ├── rcal ├── AUTHOR ├── COPYING ├── README ├── bin │ └── rcal ├── lib │ ├── calendar.rb │ ├── discordia.rb │ ├── hebrew.rb │ ├── info.rb │ └── ncal.rb ├── make.sh ├── man │ ├── rcal.1 │ └── rcal.1.ronn ├── rcal.gemspec ├── scripts │ ├── ddate.sh │ ├── dday.rb │ ├── rcal-funcs.sh │ ├── rcalhtml.sh │ ├── tcal.rb │ └── ycal.rb └── tests │ └── weeknum_test.rb ├── readme.html ├── screenshots ├── completion.png ├── html.png ├── julian.png ├── ldoc.png ├── ncal.png ├── three.png ├── weeknumers.png └── yearly.png └── scripts ├── doc ├── doomsday.sh ├── lcal-funcs.sh ├── lcal_completion ├── ldoc ├── lhtml ├── plcal_completion ├── stardate-month.sh ├── stardate.pl └── weeknum_test.sh /BUGS.md: -------------------------------------------------------------------------------- 1 | # Bugs 2 | 3 | - To maintain a (usually) fast execution, the yearly calendar and the three-month-spread (--three flag) don't support bolding. 4 | 5 | - The algorithm used for determining the day of week is limiting. I still have the Gregorian Reformation to get around. The first missing day, according to the US country code, is September 3rd 1752 and ends on the 14th. The days in between are all considered Thursday. Dates before this period need to be adjusted 11 days. 6 | 7 | Here's the mangled September 1752 calendar created by the "_Calendar Act_" of 1751: 8 | 9 | ``` 10 | September 1752 11 | Su Mo Tu We Th Fr Sa 12 | 1 2 14 15 16 13 | 17 18 19 20 21 22 23 14 | 24 25 26 27 28 29 30 15 | ``` 16 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | lcal 2 | ├── bin 3 | │   ├── cal 4 | │   ├── dcal 5 | │   ├── lcal 6 | │   ├── pc 7 | │   ├── plcal 8 | │   ├── PLCAL_README.md 9 | │   ├── rcal 10 | │   └── README.md 11 | ├── BUGS.md 12 | ├── COPYING 13 | ├── dev 14 | │   ├── css 15 | │   │   ├── default.css 16 | │   │   ├── README.md 17 | │   │   └── template.css 18 | │   ├── discordian 19 | │   │   ├── dcal 20 | │   │   ├── gd_conversion.sh 21 | │   │   ├── gdj_conversion.sh 22 | │   │   └── README.md 23 | │   ├── hebrew 24 | │   │   ├── hcal 25 | │   │   ├── hebrew.rb 26 | │   │   └── TODO.md 27 | │   ├── lcal-python 28 | │   │   ├── CalendarData.py 29 | │   │   └── README.md 30 | │   ├── locale 31 | │   │   ├── get_locale 32 | │   │   └── README.md 33 | │   ├── perpetual-scripts 34 | │   │   ├── arrays 35 | │   │   ├── leap-cycle.txt 36 | │   │   ├── leap.sh 37 | │   │   ├── matrix 38 | │   │   ├── non-leap-cycle.txt 39 | │   │   ├── non-leap.sh 40 | │   │   ├── perpetual-strings.txt 41 | │   │   ├── README.md 42 | │   │   └── string-matrix 43 | │   ├── README.md 44 | │   ├── reformation 45 | │   │   ├── lcal.dev 46 | │   │   ├── README.md 47 | │   │   └── sept1752 48 | │   └── shcal 49 | ├── docs 50 | │   ├── documentation.md 51 | │   ├── lcal.1.html 52 | │   ├── lcal-doc.html 53 | │   └── plcal.1.html 54 | ├── man 55 | │   ├── install_man 56 | │   ├── lcal.1 57 | │   ├── plcal.1 58 | │   └── showman.sh 59 | ├── MANIFEST 60 | ├── perl 61 | │   └── modules 62 | │   └── Stardate 63 | │   ├── bin 64 | │   │   ├── monthly.sh 65 | │   │   └── stardate.pl 66 | │   ├── Changes 67 | │   ├── lib 68 | │   │   └── Stardate.pm 69 | │   ├── Makefile.PL 70 | │   ├── MANIFEST 71 | │   ├── README 72 | │   └── t 73 | │   └── Stardate.t 74 | ├── rcal 75 | │   ├── AUTHOR 76 | │   ├── bin 77 | │   │   └── rcal 78 | │   ├── COPYING 79 | │   ├── lib 80 | │   │   ├── calendar.rb 81 | │   │   ├── discordia.rb 82 | │   │   ├── hebrew.rb 83 | │   │   ├── info.rb 84 | │   │   └── ncal.rb 85 | │   ├── make.sh 86 | │   ├── man 87 | │   │   ├── rcal.1 88 | │   │   └── rcal.1.ronn 89 | │   ├── rcal.gemspec 90 | │   ├── README 91 | │   ├── scripts 92 | │   │   ├── ddate.sh 93 | │   │   ├── dday.rb 94 | │   │   ├── rcal-funcs.sh 95 | │   │   ├── rcalhtml.sh 96 | │   │   ├── tcal.rb 97 | │   │   └── ycal.rb 98 | │   └── tests 99 | │   └── weeknum_test.rb 100 | ├── readme.html 101 | ├── README.md 102 | ├── screenshots 103 | │   ├── completion.png 104 | │   ├── html.png 105 | │   ├── julian.png 106 | │   ├── ldoc.png 107 | │   ├── ncal.png 108 | │   ├── three.png 109 | │   ├── weeknumers.png 110 | │   └── yearly.png 111 | ├── scripts 112 | │   ├── doc 113 | │   ├── doomsday.sh 114 | │   ├── lcal_completion 115 | │   ├── lcal-funcs.sh 116 | │   ├── ldoc 117 | │   ├── lhtml 118 | │   ├── plcal_completion 119 | │   ├── stardate-month.sh 120 | │   ├── stardate.pl 121 | │   └── weeknum_test.sh 122 | └── TODO.md 123 | 124 | 25 directories, 96 files 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lcal - display a calendar 2 | 3 | [![](https://codeclimate.com/github/ldante86/lcal/badges/gpa.svg)](https://codeclimate.com/github/ldante86/lcal) [![](https://codeclimate.com/github/ldante86/lcal/badges/issue_count.svg)](https://codeclimate.com/github/ldante86/lcal) 4 | 5 | ## DESCRIPTION 6 | 7 | **lcal** is a command-line calendar similar to cal/ncal, but written in bash. This program produces Gregorian and Julian calendars, an HTML 5 calendar, an ncal formatted calendar, weeknumbers, Discordian dates, dates of Easter (Western, Orthodox, Orthodox-Julian), monthly and yearly calendars, and Julian Day Number conversions. 8 | 9 | ## USAGE 10 | 11 | **lcal** [option] [month] [day] [year] 12 | 13 | ## OPTIONS 14 | 15 | - **-d --day-of-week** 16 | 17 | - return day of week for date 18 | 19 | - **-e --easter** 20 | 21 | - show the date for Easter (Western) 22 | 23 | - **-h --no-highlight** 24 | 25 | - disable highlighting 26 | 27 | - **-j --julian** 28 | 29 | - show Julian calendar 30 | 31 | - **-m --month** 32 | 33 | - show calendar for month (and year) 34 | 35 | - **-n --next** 36 | 37 | - show next month's calendar 38 | 39 | - **-o --orthodox** 40 | 41 | - show the date for Easter (Orthodox) 42 | 43 | - **-p --previous** 44 | 45 | - show last month's calendar 46 | 47 | - **-w --week-number** 48 | 49 | - Show week number. 50 | 51 | - **-x --date-diff** 52 | 53 | - show time between two dates. This option takes either 3 parameters or 6, as in **MM DD YYYY MM DD YYYY** or **MM DD YYYY**. If three, the current date is computed against it; if six, one date is computed against the other. 54 | 55 | - **-y --year** 56 | 57 | - show yearly calendar 58 | 59 | - **-D --discordian** 60 | 61 | - show Discordian date 62 | 63 | - **-G --gregorian-to-jdn** 64 | 65 | - convert Gregorian date to Julian day number 66 | 67 | - **-H --html** 68 | 69 | - generate an html calendar for date 70 | 71 | - **-J --jdn-to-gregorian** 72 | 73 | - convert Julian day number to Gregorian date 74 | 75 | - **-N --ncal** 76 | 77 | - show calendar in ncal mode 78 | 79 | - **-O --orthodox-julian** 80 | 81 | - show the date for Orthodox Easter as Julian date 82 | 83 | - **-V --version** 84 | 85 | - show version information and exit 86 | 87 | - **-W --show-week-number** 88 | 89 | - show week numbers next to calendar 90 | 91 | - **-1 --one** 92 | 93 | - show only the current month. Default 94 | 95 | - **-3 --three** 96 | 97 | - show last, current and next month 98 | 99 | - **--help** 100 | 101 | - show this usage and exit 102 | 103 | ## PARAMETERS 104 | 105 | Most flags can take a date string as an argument. A single parameter is either a **month** -- this will print the month for the current year -- or it is a **year** -- this will print the yearly calendar for the specified year. Two parameters are **month** and **year** -- this will print the month for the specified year. Three parameters are **month**, **day** and **year** -- this will print the specified calendar with the day highlighted. 106 | 107 | **month** can be numbers [**1-12**], or three or more letters of the month name: **jan**, **feb**, **mar**, etc. 108 | 109 | The **-m** flag is the same as **month** without the flag. A **year** can be added after **month**. 110 | 111 | To disable highlighting for **--html**, use **-h** before this flag. 112 | 113 | Flags **-1**, **-n** and **-p** stop reading arguments after them. 114 | 115 | ## TAB COMPLETION 116 | 117 | Source **/scripts/lcal_completion** for **lcal** to support tab completion. The typical location for completion scripts is **/etc/bash_completion.d/**. 118 | 119 | For current shell: 120 | 121 | ```bash 122 | cd lcal/scripts 123 | source lcal_completion 124 | ``` 125 | 126 | Make permanent: 127 | 128 | ```bash 129 | cd lcal/scripts 130 | sudo ln -fs "${PWD}"/lcal_completion /etc/bash_completion.d/lcal_completion 131 | ``` 132 | 133 | Once sourced, **lcal** can generate a list of short and long flags. 134 | 135 | For example: 136 | 137 | ```bash 138 | % lcal - [TAB][TAB] 139 | -1 -3 -d -D -e -G -h -H -j -J -m -n -N -o -O -p -V -w -W -x -y 140 | ``` 141 | 142 | ```bash 143 | % lcal -- [TAB][TAB] 144 | --date-diff --easter --html --month --no-highlight --orthodox-julian --three --year 145 | --day-of-week --gregorian-to-jdn --jdn-to-gregorian --ncal --one --previous --version 146 | --discordian --help --julian --next --orthodox --show-week-numbers --week-number 147 | ``` 148 | 149 | ## OTHER FILES 150 | 151 | - **pc** - a perpetual calendar generator. 152 | 153 | Using strings of the 14 possible calendars (7 common years, 7 leap years) and basic functions taken from **lcal** itself, **pc** can generate any monthly calendar. It is fast and lightweight, and unlike **lcal**, **pc** is compatable with the Korn Shell. 154 | 155 | Development scripts for **pc** can be found in _dev/perpetual-scripts_ 156 | 157 | - **cal** - a perpetual calendar generator. 158 | 159 | This is like **pc** above, but it is used to only print the current calendar and does not accept any flags other than the *-h* flag for unbolding. **cal** is designed to be the smallest program of the lot. 160 | 161 | - **dcal** - print the Discordian calendar. 162 | 163 | This script prints a formatted calendar based on the Discordian seasons. See the [README](https://github.com/ldante86/lcal/blob/master/dev/discordian/README.md) for **dcal** for more information. 164 | 165 | - **plcal** - a calendar written in perl. 166 | 167 | This calendar is the start of what might some day become the "finished product." Still in development, yet functional as it is now, **plcal** will discard all of the trappings and disadvantages of bash and be fully portable between operating systems. 168 | 169 | - dev/**shcal** - a POSIX compliant calendar. 170 | 171 | This program is slowly coming together, but when it is finished it will be sh-dash-ash-zsh-bash-ksh compliant. 172 | 173 | ## BUGS 174 | 175 | So far, **lcal** does not account for the Gregorian Reformation. so the year range is currently **1753 - 9999**. The algorithm I used for calculating the day of week does not use Julian Day Numbers -- which it should. 176 | 177 | See: [BUGS](https://github.com/ldante86/lcal/blob/master/BUGS.md) 178 | 179 | ## VERSION 180 | 181 | 1.0.0 182 | 183 | ## SEE ALSO 184 | 185 | cal, ddate, ncal, gcal, ccal, when 186 | 187 | ## LICENSE 188 | 189 | **(c) 2014-2017 Luciano D. Cecere - ldante86@aol.com** 190 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TODO for lcal 2 | 3 | - I need a small parser function to catch illegal flag combinations. Right now flags are processed by precedence on the command-line. The main function has sort of a parser, but it does not cover everything. 4 | 5 | Combinations like this should not be legal: 6 | 7 | ``` 8 | % lcal --one --three --html 9 | ``` 10 | 11 | - Work on **[dcal](https://github.com/ldante86/lcal/tree/master/dev/discordian)**. 12 | 13 | - _day_of_week needs to be using Julian Day Numbers so lcal can compute past the Gregorian Reformation - years 0-9999. 14 | 15 | - Add support for different locales. Start week on Monday, etc. `locale -c LC_TIME` 16 | - Provide capability to load CSS files - --css file.css, etc 17 | - Finish Hebrew calendar code and incorporate it into lcal. --hebrew, etc. 18 | - Add holiday list. 19 | - Add appointments and special dates. Boldable, requires a more sophisticaed print function. 20 | - Make a config file, locales, appointments, etc. 21 | - Add ASCII colors. 22 | - Make ldoc print function comments. 23 | - ~~Make a perpetual calendar with arrays.~~ DONE 24 | 25 | # Any contributions or rough-drafts are welcome! 26 | -------------------------------------------------------------------------------- /bin/PLCAL_README.md: -------------------------------------------------------------------------------- 1 | README for plcal-0.0.1 2 | 3 | ### PROGRAM 4 | 5 | **plcal** 6 | 7 | ### DESCRIPTION 8 | 9 | **plcal** is a simple command-line calendar written in perl. 10 | 11 | ### USAGE 12 | 13 | **plcal** [option] [--date=**mm yyyy**] 14 | 15 | ### OPTIONS 16 | 17 | | Option | Description | 18 | | :------------- | :------------- | 19 | | -b | Use bracketed bolding (<>) | 20 | | -h | Disable highlighting | 21 | | -n | Show next month | 22 | | -p | Show previous month 23 | | --date=**mm yyyy** | Display a calendar for a specified month and year | 24 | | --help | Show hexp text and exit | 25 | | --month=**mm** | Show specified month | 26 | 27 | ### EXAMPLE 28 | 29 | Command: 30 | 31 | ``` 32 | plcal --date=10 1986 33 | ``` 34 | 35 | Output: 36 | ``` 37 | October 1986 38 | Su Mo Tu We Th Fr Sa 39 | 1 2 3 4 40 | 5 6 7 8 9 10 11 41 | 12 13 14 15 16 17 18 42 | 19 20 21 22 23 24 25 43 | 26 27 28 29 30 31 44 | 45 | ``` 46 | 47 | ### NOTES 48 | 49 | The **-b** option will be the default if the OS is Windows. 50 | 51 | ### AUTHOR 52 | 53 | The program **plcal** and this documentation was written by Luciano D. Cecere . 54 | 55 | ### LICENSE 56 | 57 | **plcal** is free software; you can redistribute it and/or modify it under the terms of the GPL, or, optionally, Perl's license. 58 | -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | # Executable files 2 | 3 | ## lcal - a command-line calendar 4 | 5 | ## pc - a perpetual calendar generator 6 | 7 | ``` 8 | pc [mm [dd [yyyy]]] [-h] [--help] 9 | ``` 10 | 11 | ## cal - print only the current calendar 12 | 13 | ``` 14 | cal [-h] 15 | ``` 16 | 17 | ## plcal - a perl version of cal 18 | ``` 19 | plcal [-h] 20 | ``` 21 | -------------------------------------------------------------------------------- /bin/dcal: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | # 3 | # SCRIPT: dcal 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 11/29/2016-04:59:55 PM 6 | ######################################################################## 7 | # 8 | # dcal - print the Discordian calendar 9 | # Copyright (C) 2016 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | PROGRAM="${0##*/}" 27 | 28 | _month_array() 29 | { 30 | if (($1 % 4 == 0 )) && 31 | (($1 % 100 == 0 )) || 32 | (($1 % 400 == 0 )); then 33 | len=("" 31 29 31 30 31 30 31 31 30 31 30 31) 34 | else 35 | len=("" 31 28 31 30 31 30 31 31 30 31 30 31) 36 | fi 37 | } 38 | 39 | _discordian_date() 40 | { 41 | if (( $# != 3 )); then 42 | echo "Invalid date" 43 | exit 1 44 | fi 45 | 46 | m=$1 47 | d=$2 48 | y=$3 49 | dy=$((y + 1166)) 50 | 51 | if (( m > 12 )); then 52 | echo "Month ouf of range of year" 53 | exit 1 54 | fi 55 | 56 | _month_array $y 57 | if (( d > len[m] )) || (( d <= 0 )); then 58 | echo "Day out of range of month - [1-${len[m]}]" 59 | exit 1 60 | fi 61 | 62 | unset tib 63 | if (( len[m] == 29 )) && (( m == 2 )) && (( d == 29 )); then 64 | tib=1 65 | fi 66 | 67 | days=$d 68 | 69 | for (( x=1; x<$m; x++ )) 70 | do 71 | ((days+=len[x])) 72 | done 73 | 74 | doy=$days 75 | 76 | if (( len[2] == 29 )) && (( doy >= 60 )); then 77 | ((--doy)) 78 | fi 79 | 80 | seasonday=$(( doy % 73 )) 81 | if (( seasonday == 0 )); then 82 | seasonday=73 83 | fi 84 | 85 | seasons=(Chaos Discord Confusion Bureaucracy "The Aftermath") 86 | case $doy in 87 | 73|146|219|291|365) 88 | season="${seasons[ $(( doy / 73)) - 1 ]}" ;; 89 | *) 90 | season="${seasons[ $(( doy / 73)) ]}" ;; 91 | esac 92 | } 93 | 94 | _discordian_array() 95 | { 96 | disc=() 97 | space=" " # 5 spaces 98 | case $season in 99 | Chaos) 100 | true 101 | ;; 102 | Discord) 103 | disc+=("$space" "$space" "$space") 104 | ;; 105 | Confusion) 106 | disc+=("$space") 107 | ;; 108 | Bureaucracy) 109 | disc+=("$space" "$space" "$space" "$space") 110 | ;; 111 | "The Aftermath") 112 | disc+=("$space" "$space" ) 113 | ;; 114 | esac 115 | 116 | for (( i=1; i<74; i++ )) 117 | do 118 | if (( i < 10 )); then 119 | if (( i == 5 )); then 120 | disc+=(" *5 ") 121 | else 122 | disc+=(" $i ") 123 | fi 124 | elif (( i == 50 )); then 125 | disc+=(" *50 ") 126 | else 127 | disc+=(" $i ") 128 | fi 129 | done 130 | } 131 | 132 | _print_discordian_calendar() 133 | { 134 | _discordian_date "$@" 135 | _discordian_array 136 | 137 | today=$d 138 | d=$seasonday 139 | case ${#d} in 140 | 1) 141 | d=" $d" 142 | ;; 143 | 2) 144 | d=" $d" 145 | ;; 146 | esac 147 | 148 | unset no_highlight 149 | if [ $tib ]; then 150 | no_highlight=1 151 | fi 152 | 153 | case $seasonday in 154 | 5) 155 | d="*5 " 156 | ;; 157 | 50) 158 | d="*50" 159 | ;; 160 | esac 161 | 162 | echo " $season $dy" 163 | echo " SM BT PD PP SO" 164 | 165 | for (( i=0; i<${#disc[@]}; i++ )) 166 | do 167 | if (( i % 5 == 0 )) && (( i != 0 )); then 168 | printf "\n" 169 | fi 170 | if [ "$d " = "${disc[i]}" ] || [ " $d " = "${disc[i]}" ] || [ " $d" = "${disc[i]}" ]; then 171 | printf "\e[7m%s\e[27m" "${disc[i]}" 172 | else 173 | printf "%s" "${disc[i]}" 174 | fi 175 | done 176 | echo 177 | } 178 | 179 | case $# in 180 | 1) 181 | m="$1" 182 | d="$(printf "%(%_d)T")" 183 | y="$(printf "%(%_Y)T")" 184 | ;; 185 | 2) 186 | m="$1" 187 | d="$(printf "%(%_d)T")" 188 | y="$2" 189 | ;; 190 | 3) 191 | m="$1" 192 | d="$2" 193 | y="$3" 194 | ;; 195 | *) 196 | m="$(printf "%(%_m)T")" 197 | d="$(printf "%(%_d)T")" 198 | y="$(printf "%(%_Y)T")" 199 | ;; 200 | esac 201 | 202 | _print_discordian_calendar $m $d $y 203 | -------------------------------------------------------------------------------- /bin/plcal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # SCRIPT: plcal 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 10/19/2017 6 | ######################################################################## 7 | # 8 | # plcal - Display a calendar 9 | # Copyright (C) 2017 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | use strict; 27 | use warnings; 28 | use 5.010; 29 | use POSIX qw(strftime); 30 | use Getopt::Long; 31 | 32 | ## Global variables ## 33 | 34 | my @month_length; 35 | my @calendar_data; 36 | my $month_starts_on; 37 | 38 | my @month_names_long = qw( undef January February March April May June 39 | July August September October November December ); 40 | my @month_names_short 41 | = qw( undef Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); 42 | my @day_names_long 43 | = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); 44 | my @day_names_short = qw ( Sun Mon Tue Wed Thu Fri Sat ); 45 | my @day_names_shorter = qw ( Su Mo Tu We Th Fr Sa ); 46 | 47 | my $bold_on = "\e[7m"; 48 | my $bold_off = "\e[27m"; 49 | my $space = " "; 50 | my $calendar_length = 42; 51 | my $calendar_width = 21; 52 | 53 | my $month = strftime "%m", localtime; 54 | my $day = strftime "%d", localtime; 55 | my $year = strftime "%Y", localtime; 56 | 57 | ## Subroutines ## 58 | 59 | sub help { 60 | return << 'HELP'; 61 | 62 | plcal - display a monthly calendar 63 | 64 | Usage: plcal [option] 65 | 66 | Options: 67 | -b use bracketed bolding (<>) 68 | -h disable highlighting 69 | -n show next month 70 | -p show previous month 71 | --date=mm yyyy display month of year 72 | --help display this help and exit 73 | --month=mm show specified month 74 | 75 | Copyright (C) 2017 Luciano D. Cecere 76 | 77 | HELP 78 | } 79 | 80 | sub get_month_length { 81 | my $y = $_[0]; 82 | if ( ( $y % 4 == 0 and $y % 100 != 0 ) or $y % 400 == 0 ) { 83 | @month_length = qw( 0 31 29 31 30 31 30 31 31 30 31 30 31 ); 84 | } 85 | else { 86 | @month_length = qw( 0 31 28 31 30 31 30 31 31 30 31 30 31 ); 87 | } 88 | } 89 | 90 | sub day_of_week { 91 | my ( $m, $d, $y ) = @_; 92 | my @arr = qw( undef 6 2 2 5 0 3 5 1 4 6 2 4 ); 93 | my $w 94 | = ( ( int( $y / 4 ) ) - ( int( $y / 100 ) ) ) 95 | + ( int( $y / 400 ) ) 96 | + $d + $y 97 | + $arr[$m]; 98 | 99 | if ( $month_length[2] == 29 and $m < 3 ) { $w--; } 100 | 101 | $w % 7; 102 | } 103 | 104 | sub day_in_year { 105 | my ( $m, $d, $y ) = @_; 106 | my $i; 107 | 108 | for ( $i = 1; $i <= ( $m - 1 ); $i++ ) { 109 | get_month_length($y); 110 | $d += $month_length[$i]; 111 | } 112 | $d; 113 | } 114 | 115 | sub center { 116 | my ( $len, $str ) = @_; 117 | printf "%*s\n", ( length($str) + $len ) / 2, $str; 118 | } 119 | 120 | sub gregorian_data { 121 | @calendar_data = (); 122 | my ( $m, $y ) = @_; 123 | get_month_length($y); 124 | $month_starts_on = day_of_week( $m, 1, $y ); 125 | my $len = $month_length[$m]; 126 | my $i; 127 | 128 | for ( $i = 1; $i <= $month_starts_on; $i++ ) { 129 | last if ( $month_starts_on == 0 ); 130 | push @calendar_data, "$space" x 2; 131 | } 132 | 133 | for ( $i = 1; $i <= ( $calendar_length - $month_starts_on ); $i++ ) { 134 | if ( $i < 10 ) { 135 | push @calendar_data, "$space$i"; 136 | } 137 | elsif ( $i > $len ) { 138 | push @calendar_data, "$space" x 3; 139 | } 140 | else { 141 | push @calendar_data, "$i"; 142 | } 143 | } 144 | } 145 | 146 | sub print_gregorian_month { 147 | my ( $m, $d, $y ) = @_; 148 | $d =~ s/^\s+//; 149 | my $dd = $d; 150 | $d =~ s/^0+//; 151 | 152 | gregorian_data( $m, $y ); 153 | 154 | print "\n"; 155 | center( $calendar_width, "$space$month_names_long[$m] $y" ); 156 | print "$space@day_names_shorter\n"; 157 | 158 | my $i; 159 | for ( $i = 0; $i < $#calendar_data; $i++ ) { 160 | if ( ( $i % 7 ) == 0 and $i != 0 ) { 161 | print "\n"; 162 | } 163 | if ( ( $i - ( $month_starts_on - 1 ) == $dd ) 164 | and ( $i - ( $month_starts_on - 1 ) < 10 ) 165 | and $dd > 0 ) 166 | { 167 | print "$space$bold_on$space$d$bold_off"; 168 | } 169 | elsif (( $i - ( $month_starts_on - 1 ) == $dd ) 170 | and ( $i - ( $month_starts_on - 1 ) > 9 ) 171 | and $dd > 0 ) 172 | { 173 | print "$space$bold_on$d$bold_off"; 174 | } 175 | else { 176 | print "$space$calendar_data[$i]"; 177 | } 178 | } 179 | print "\n"; 180 | } 181 | 182 | sub print_gregorian_month_brackets { 183 | my ( $m, $d, $y ) = @_; 184 | $d =~ s/^\s+//; 185 | $d =~ s/^0+//; 186 | 187 | gregorian_data( $m, $y ); 188 | 189 | my $sp = ''; 190 | 191 | print "\n"; 192 | center( $calendar_width, "$space$month_names_long[$m] $y" ); 193 | print "$space@day_names_shorter\n"; 194 | 195 | my $i; 196 | for ( $i = 0; $i < $#calendar_data; $i++ ) { 197 | if ( ( $i % 7 ) == 0 and $i != 0 ) { 198 | print "\n"; 199 | } 200 | if ( ( $i - ( $month_starts_on - 1 ) == $d ) 201 | and ( $i - ( $month_starts_on - 1 ) < 10 ) 202 | and $d > 0 ) 203 | { 204 | print "<$space$d>"; 205 | $sp = 1; 206 | } 207 | elsif (( $i - ( $month_starts_on - 1 ) == $d ) 208 | and ( $i - ( $month_starts_on - 1 ) > 9 ) 209 | and $d > 0 ) 210 | { 211 | print "<$d>"; 212 | $sp = 1; 213 | } 214 | else { 215 | if ( $sp and day_of_week( $m, $d, $y ) == 6 ) { 216 | print "$space$calendar_data[$i]"; 217 | $sp = ''; 218 | } 219 | elsif ($sp) { 220 | print "$calendar_data[$i]"; 221 | $sp = ''; 222 | } 223 | else { 224 | print "$space$calendar_data[$i]"; 225 | } 226 | } 227 | } 228 | print "\n"; 229 | } 230 | 231 | sub validate_month { 232 | my $m = $_[0]; 233 | 234 | if ( $m < 1 or $m > 12 ) { 235 | print "Month out of range [1-12]\n"; 236 | exit 1; 237 | } 238 | } 239 | 240 | sub increment_month { 241 | my $m = $_[0]; 242 | 243 | if ( $m == 12 ) { 244 | $month = 1; 245 | $year++; 246 | } 247 | else { 248 | $month++; 249 | } 250 | $day = 0; 251 | } 252 | 253 | sub decrement_month { 254 | my $m = $_[0]; 255 | 256 | if ( $month == 1 ) { 257 | $month = 12; 258 | $year--; 259 | } 260 | else { 261 | $month--; 262 | } 263 | $day = 0; 264 | } 265 | 266 | ## Parse commandline args ### 267 | 268 | my $help = ''; 269 | my $bold = ''; 270 | my $no_highlight = ''; 271 | my @date_my = (); 272 | my $month1 = ''; 273 | my $next = ''; 274 | my $previous = ''; 275 | 276 | GetOptions( 277 | 'b|bracket' => \$bold, 278 | 'help|info' => \$help, 279 | 'h' => \$no_highlight, 280 | 'date=i{2}' => \@date_my, 281 | 'month=i{0,}' => \$month1, 282 | 'n|next' => \$next, 283 | 'p|previous' => \$previous, 284 | ); 285 | 286 | ## Program start ## 287 | 288 | if ($help) { 289 | print help(); 290 | exit; 291 | } 292 | 293 | if ($previous) { 294 | decrement_month($month); 295 | print_gregorian_month( $month, $day, $year ); 296 | exit; 297 | } 298 | 299 | if ($next) { 300 | increment_month($month); 301 | print_gregorian_month( $month, $day, $year ); 302 | exit; 303 | } 304 | 305 | if ($no_highlight) { 306 | $day = 0; 307 | } 308 | 309 | if ($month1) { 310 | validate_month($month1); 311 | $day = 0; 312 | print_gregorian_month( $month1, $day, $year ); 313 | exit; 314 | } 315 | 316 | if ( $#date_my > 0 ) { 317 | $month = $date_my[0]; 318 | $year = $date_my[1]; 319 | $day = 0; 320 | } 321 | 322 | if ( "$^O" eq 'MSWin32' or $bold ) { 323 | if ($no_highlight) { 324 | $day = 0; 325 | } 326 | else { 327 | print_gregorian_month_brackets( $month, $day, $year ); 328 | exit; 329 | } 330 | } 331 | 332 | #Standard calendar - no options 333 | print_gregorian_month( $month, $day, $year ); 334 | 335 | __END__ 336 | 337 | ## Manpage documentation below. Process with pod2man. 338 | 339 | =head1 NAME 340 | 341 | plcal - Display a monthly calendar 342 | 343 | =head1 SYNOPSIS 344 | 345 | plcal [option] 346 | plcal --help 347 | 348 | =head1 DESCRIPTION 349 | 350 | plcal is a simple command-line calendar written in perl. 351 | 352 | =head1 OPTIONS 353 | 354 | =over 12 355 | 356 | =item -b 357 | 358 | Use bracketed bolding (<>). 359 | 360 | =item -h 361 | 362 | Disable highlighting. 363 | 364 | =item -n 365 | 366 | Show next nomth. 367 | 368 | =item -p 369 | 370 | Show previous month. 371 | 372 | =item --help 373 | 374 | Display a help text and exit. 375 | 376 | =item --date=B B 377 | 378 | Display a calendar for a specified month and year. 379 | 380 | =item --month=B 381 | 382 | Show specified month in current year. 383 | 384 | =back 385 | 386 | =head1 NOTES 387 | 388 | The -b option will be the default if the OS is Windows. 389 | 390 | =head1 AUTHOR 391 | 392 | Luciano D. Cecere 393 | 394 | =head1 LICENSE 395 | 396 | B is free software; you can redistribute it and/or modify it 397 | under the terms of the GPL, or, optionally, Perl's license. 398 | 399 | =cut 400 | -------------------------------------------------------------------------------- /bin/rcal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # encoding: utf-8 3 | # 4 | # SCRIPT: rcal.rb 5 | # AUTHOR: Luciano D. Cecere 6 | # DATE: 12/2015 7 | ######################################################################## 8 | # 9 | # rcal.rb - Display a calendar 10 | # Copyright (C) 2015 Luciano D. Cecere 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 2 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this program. If not, see . 24 | # 25 | ######################################################################## 26 | 27 | require '../rcal/lib/calendar' 28 | require '../rcal/lib/ncal' 29 | require '../rcal/lib/discordia' 30 | require '../rcal/lib/info' 31 | 32 | month = Calendar::MONTH 33 | day = Calendar::DAY 34 | year = Calendar::YEAR 35 | 36 | USAGE = "\ 37 | 38 | PROGRAM: rcal - display a calendar 39 | AUTHOR: Luciano D. Cecere 40 | LICENSE: GPLv2 (2015) 41 | 42 | USAGE: 43 | rcal show current calendar 44 | rcal MM show month of current year 45 | rcal MM YYYY show month of year 46 | rcal MM DD YYYY show month and day of year 47 | rcal -d MM DD YYYY MM DD YYYY show days/years between two dates 48 | rcal -e YYYY show Western easter for YYYY 49 | rcal -h don't highlight the current day 50 | rcal -j MM DD YYYY show Julian (1..365) calendar 51 | rcal -n show next month 52 | rcal -p show previous month 53 | rcal -w MM DD YYYY show week numbers 54 | rcal -y YYYY show yearly calendar 55 | rcal -D MM DD YYYY show day of week for date 56 | rcal -G MM DD YYYY show Julian day number (JDN) for date 57 | rcal -J JDN show Gregorian date for JDN 58 | rcal -V show version information and exit 59 | rcal -W show current week number 60 | rcal --ddate MM DD YYYY show Discordian date for date 61 | rcal --help show this help and exit 62 | rcal --html MM DD YYYY generate HTML calendar 63 | rcal --ncal MM DD YYYY show calendar in ncal format 64 | rcal -3 MM YYYY show previous, current and next month 65 | 66 | NOTES: 67 | The -h flag must precede all other flags and args. 68 | With the -3 flag, the middle month and year can be set. 69 | The -y flag is optional if year is by itself. 70 | 71 | " 72 | 73 | ### PARSE COMMAND LINE OPTIONS ### 74 | 75 | if(ARGV[0] == "--help") then 76 | puts(USAGE) 77 | exit 78 | end 79 | 80 | if(ARGV[0] == "-V") then 81 | puts "rcal #{Rcal_info::VERSION}" 82 | puts "#{Rcal_info::INFO}" 83 | exit 84 | end 85 | 86 | cal = Calendar.new(month, day, year) 87 | 88 | julian = nil 89 | show_week = nil 90 | html = nil 91 | three = nil 92 | ncal = nil 93 | no_highlight = nil 94 | 95 | if(ARGV[0] == "-3") then 96 | ARGV.shift 97 | three = 1 98 | end 99 | 100 | if(ARGV[0] == "-y") then 101 | ARGV.shift 102 | if(ARGV.length == 1) then 103 | cal.d = nil 104 | cal.y = ARGV[0] 105 | cal.yearly 106 | else 107 | cal.d = nil 108 | cal.yearly 109 | end 110 | exit 111 | end 112 | 113 | if(ARGV[0] == "--ddate") then 114 | d = Discordia.new(month, day, year) 115 | ARGV.shift 116 | if(ARGV.length == 3) then 117 | d.m, d.d, d.y = ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i 118 | end 119 | d.print_discordian_date 120 | exit 121 | end 122 | 123 | if(ARGV[0] == "-d") then 124 | ARGV.shift 125 | if(ARGV.length == 6) then 126 | cal.diff_date_2(ARGV[0], ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5]) 127 | exit 128 | elsif(ARGV.length == 3) then 129 | cal.diff_date_1(ARGV[0], ARGV[1], ARGV[2]) 130 | exit 131 | else 132 | puts("The -d flag format is: MM DD YYYY MM DD YYYY") 133 | puts Calendar::HELP 134 | exit 1 135 | end 136 | end 137 | 138 | if(ARGV[0] == "-D") then 139 | ARGV.shift 140 | if(ARGV.length == 3) then 141 | cal.m, cal.d, cal.y = ARGV[0], ARGV[1], ARGV[2] 142 | puts Calendar::WEEKDAYS[cal.day_of_week(cal.m, cal.d, cal.y)] 143 | exit 144 | elsif(ARGV.length == 0) then 145 | puts Calendar::WEEKDAYS[cal.day_of_week(month, day, year)] 146 | exit 147 | else 148 | puts("Not enought args") 149 | puts Calendar::HELP 150 | exit 1 151 | end 152 | end 153 | 154 | if(ARGV[0] == "-e") then 155 | ARGV.shift 156 | if(ARGV.length == 1) then 157 | month, day, year = cal.western_easter(ARGV[0]) 158 | m = Calendar::MONTH_NAMES[month] 159 | puts("#{m} #{day} #{year}") 160 | else 161 | month, day, year = cal.get_western_easter 162 | m = Calendar::MONTH_NAMES[month] 163 | puts("#{m} #{day} #{year}") 164 | end 165 | exit 166 | end 167 | 168 | if(ARGV[0] == "-G") then 169 | ARGV.shift 170 | if(ARGV.length == 3) then 171 | month, day, year = ARGV[0], ARGV[1], ARGV[2] 172 | end 173 | puts(cal.gregorian_date_to_julian_date(month, day, year)) 174 | exit 175 | end 176 | 177 | if(ARGV[0] == "-J") then 178 | ARGV.shift 179 | if(ARGV.length != 1) then 180 | puts("Mising Julian day number") 181 | puts Calendar::HELP 182 | exit 1 183 | end 184 | month, day, year = cal.julian_day_to_gregorian_day(ARGV[0]) 185 | puts("#{month} #{day} #{year}") 186 | exit 187 | end 188 | 189 | if(ARGV[0] == "-h") then 190 | ARGV.shift 191 | no_highlight = 1 192 | cal.d = nil 193 | end 194 | 195 | if(ARGV[0] == "--html") then 196 | ARGV.shift 197 | html = 1 198 | end 199 | 200 | if(ARGV[0] == "-j") then 201 | ARGV.shift 202 | julian = 1 203 | if(ARGV.length == 1) then 204 | if(ARGV[0] == "-y") then 205 | cal.d = nil 206 | cal.j_yearly 207 | exit 208 | else 209 | cal.m = ARGV[0] 210 | cal.d = nil 211 | end 212 | elsif(ARGV.length == 2) then 213 | if(ARGV[0] == "-y") then 214 | cal.y = ARGV[1] 215 | cal.d = nil 216 | cal.j_yearly 217 | exit 218 | else 219 | cal.m, cal.y = ARGV[0], ARGV[1] 220 | cal.d = nil 221 | end 222 | elsif(ARGV.length == 3) then 223 | cal.m, cal.d, cal.y = ARGV[0], ARGV[1], ARGV[2] 224 | end 225 | cal.d = nil if(no_highlight) 226 | end 227 | 228 | if(ARGV[0] == "--ncal") then 229 | ncal = 1 230 | nc = Ncal.new(month, day, year) 231 | ARGV.shift 232 | if(ARGV.length == 1) then 233 | if(ARGV[0] == "-y") then 234 | nc.d = nil 235 | nc.ncal_yearly 236 | exit 237 | elsif(ARGV[0] == "-j") then 238 | nc.d = nil if(no_highlight) 239 | nc.j_print_ncal 240 | exit 241 | else 242 | nc.m = ARGV[0] 243 | nc.d = nil 244 | end 245 | elsif(ARGV.length == 2) then 246 | if(ARGV[0] == "-j") && (ARGV[1] == "-y") then 247 | nc.d = nil 248 | nc.j_ncal_yearly 249 | exit 250 | elsif(ARGV[0] == "-j") then 251 | nc.m = ARGV[1] 252 | nc.d = nil 253 | nc.j_print_ncal 254 | exit 255 | elsif(ARGV[0] == "-y") then 256 | nc.y = ARGV[1] 257 | nc.d = nil 258 | nc.ncal_yearly 259 | exit 260 | else 261 | nc.m = ARGV[0] 262 | nc.y = ARGV[1] 263 | nc.d = nil 264 | end 265 | elsif(ARGV.length == 3) then 266 | if(ARGV[0] == "-j") && (ARGV[1] == "-y") then 267 | nc.y = ARGV[2] 268 | nc.d = nil 269 | nc.j_ncal_yearly 270 | exit 271 | end 272 | if(ARGV[0] == "-j") then 273 | nc.m = ARGV[1] 274 | nc.y = ARGV[2] 275 | nc.d = nil 276 | nc.j_print_ncal 277 | exit 278 | else 279 | nc.m, nc.d, nc.y = ARGV[0], ARGV[1], ARGV[2] 280 | nc.d = nil if(no_highlight) 281 | end 282 | elsif(ARGV.length == 4) then 283 | if(ARGV[0] == "-j") 284 | nc.m, nc.d, nc.y = ARGV[1], ARGV[2], ARGV[3] 285 | nc.d = nil if(no_highlight) 286 | nc.j_print_ncal 287 | exit 288 | end 289 | elsif(ARGV.length == 2) then 290 | nc.m, nc.d, nc.y = ARGV[0], nil, ARGV[1] 291 | end 292 | end 293 | 294 | if(ARGV[0] == "-w") then 295 | ARGV.shift 296 | show_week = 1 297 | end 298 | 299 | if(ARGV[0] == "-W") then 300 | puts cal.week_num(month.to_i, day.to_i, year.to_i) 301 | exit 302 | end 303 | 304 | if(ARGV[0] == "-p") then 305 | cal.shift_month_backward 306 | cal.print_g_monthly 307 | exit 308 | end 309 | 310 | if(ARGV[0] == "-n") then 311 | cal.shift_month_forward 312 | cal.print_g_monthly 313 | exit 314 | end 315 | 316 | if(ARGV.length == 1) then 317 | if(ARGV[0].to_i >= 1753) && (ARGV[0].to_i <= 9999) then 318 | cal.d = nil 319 | cal.y = ARGV[0] 320 | cal.yearly 321 | exit 322 | else 323 | cal.m, cal.d = ARGV[0].to_i, nil 324 | end 325 | end 326 | 327 | if(ARGV.length == 2) then 328 | cal.m, cal.d, cal.y = ARGV[0].to_i, nil, ARGV[1].to_i 329 | end 330 | 331 | if(ARGV.length == 3) then 332 | cal.m, cal.d, cal.y = ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i 333 | end 334 | 335 | cal.d = nil if(no_highlight) 336 | 337 | ### PROGRAM START ### 338 | 339 | if(julian) 340 | cal.print_j_monthly 341 | elsif(show_week) 342 | cal.print_weeknums 343 | elsif(html) 344 | cal.to_html 345 | elsif(three) 346 | cal.month3 347 | elsif(ncal) 348 | nc.d = nil if(no_highlight) 349 | nc.print_ncal 350 | else 351 | cal.print_g_monthly 352 | end 353 | 354 | ### EOF #################################################################### 355 | -------------------------------------------------------------------------------- /dev/README.md: -------------------------------------------------------------------------------- 1 | # dev 2 | 3 | ## A place for features still in development. 4 | -------------------------------------------------------------------------------- /dev/css/README.md: -------------------------------------------------------------------------------- 1 | # CSS 2 | 3 | ## This is a place for loadable css files. In future, a --css flag will be able to load a local css file to the html calendar. 4 | 5 | ## Use template.txt to create a css file compatable with lcal 6 | -------------------------------------------------------------------------------- /dev/css/default.css: -------------------------------------------------------------------------------- 1 | body{background:gray} 2 | table{background:#000;border:2px solid #000} 3 | table.center{margin-left:auto;margin-right:auto} 4 | .month{font-size:50px;word-spacing:.5em;color:#FFF;font-weight:700} 5 | td{font-family:Arial;text-align:center;font-size:25px;width:82px;height:82px;padding:0;font-weight:700} 6 | .weekbar{height:10px;background:#232323;color:#FFF} 7 | .sunday{background-color:#606060;color:#FFF;font-style:italic} 8 | .weekday{background-color:silver} 9 | .today{background-color:red;font-size:35px;color:#FFF} 10 | .today:hover{background-color:#000;color:red} 11 | @media only print { 12 | body{background:#fff;color:#000} 13 | .sunday{font-size:30px} 14 | .weekday{font-size:30px;font-weight:400} 15 | .today{text-decoration:underline} 16 | } 17 | -------------------------------------------------------------------------------- /dev/css/template.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Body definition 3 | */ 4 | body{} 5 | 6 | /* 7 | * Table definition. 8 | */ 9 | table{} 10 | 11 | /* 12 | * Center table. 13 | */ 14 | table.center{margin-left:auto;margin-right:auto} 15 | 16 | /* 17 | * Month name row. 18 | */ 19 | .month{} 20 | 21 | /* 22 | * Body of calendar. 23 | */ 24 | td{} 25 | 26 | /* 27 | *The week name row. 28 | */ 29 | .weekbar{} 30 | 31 | /* 32 | * Sunday column should look different than .weekday 33 | */ 34 | .sunday{} 35 | 36 | /* 37 | * Formatting for days other than Sunday. 38 | */ 39 | .weekday{} 40 | 41 | /* 42 | * Make today look special! 43 | */ 44 | .today{} 45 | 46 | /* 47 | * Mouse-over today - change color. 48 | */ 49 | .today:hover{} 50 | 51 | /* 52 | * Instructions for sending to a printer. 53 | */ 54 | @media only print { 55 | body{} 56 | .sunday{} 57 | .weekday{} 58 | .today{} 59 | } 60 | -------------------------------------------------------------------------------- /dev/discordian/README.md: -------------------------------------------------------------------------------- 1 | # README for discordia 2 | 3 | ## **dcal** - print the Discordian calendar 4 | 5 | **dcal** represents each of the five seasons of the Discordian year. There are 73 days within each season. Every year is 365 days long and every four years there is a non-existent day called St. Tibs; this day occurs between days 59 and 60 in the month of Chaos -- February 29 to the rest of us. The five seasons are: _Chaos_, _Discord_, _Confusion_, _Bureaucracy_, and _The Aftermath_. There are five days in a Discordian week: _Sweetmorn_, _Boomtime_, _Pungenday_, _Prickle-Prickle_, and _Setting Orange_. Aside from St. Tibs day, there are 5 season holydays that occur on the 5th day of each season: _Chaoflux_, _Discoflux_, _Confuflux_, _Bureflux_, and _Afflux_ -- and 5 Apostle holydays that occur on the 50th day of each season: _Mungday_, _Mojoday_, _Syaday_, _Zaraday_, and _Maladay_. These days are represented with an asterisk. St. Tibs day will not be shown! The Discordian year is 1166 added to the civil year: 2016 + 1166 = 3182. 6 | 7 | **dcal** prints the season in which the Gregorian _date_ falls. A season spans multiple months -- the season of Chaos starts on January 1st and ends on March 14th, etc. 8 | 9 | Discordian dates are handled by **lcal** 10 | 11 | ``` 12 | % lcal --discordian 2 28 2016 13 | Today is Prickle-Prickle, the 59th day of Chaos in the YOLD 3182 14 | 15 | % lcal --discordian 2 29 2016 16 | St. Tib's Day, 3182 YOLD 17 | 18 | % lcal --discordian 3 1 2016 19 | Today is Setting Orange, the 60th day of Chaos in the YOLD 3182 20 | ``` 21 | 22 | ## See also 23 | 24 | [Discordian calendar](https://en.wikipedia.org/wiki/Discordian_calendar) 25 | 26 | [ddate](http://linuxcommand.org/man_pages/ddate1.html) 27 | -------------------------------------------------------------------------------- /dev/discordian/dcal: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | # 3 | # SCRIPT: dcal 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 11/29/2016-04:59:55 PM 6 | ######################################################################## 7 | # 8 | # dcal - print the Discordian calendar 9 | # Copyright (C) 2016 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | PROGRAM="${0##*/}" 27 | 28 | _month_array() 29 | { 30 | if (($1 % 4 == 0 )) && 31 | (($1 % 100 == 0 )) || 32 | (($1 % 400 == 0 )); then 33 | len=("" 31 29 31 30 31 30 31 31 30 31 30 31) 34 | else 35 | len=("" 31 28 31 30 31 30 31 31 30 31 30 31) 36 | fi 37 | } 38 | 39 | _discordian_date() 40 | { 41 | if (( $# != 3 )); then 42 | echo "Invalid date" 43 | exit 1 44 | fi 45 | 46 | m=$1 47 | d=$2 48 | y=$3 49 | dy=$((y + 1166)) 50 | 51 | if (( m > 12 )); then 52 | echo "Month ouf of range of year" 53 | exit 1 54 | fi 55 | 56 | _month_array $y 57 | if (( d > len[m] )) || (( d <= 0 )); then 58 | echo "Day out of range of month - [1-${len[m]}]" 59 | exit 1 60 | fi 61 | 62 | unset tib 63 | if (( len[m] == 29 )) && (( m == 2 )) && (( d == 29 )); then 64 | tib=1 65 | fi 66 | 67 | days=$d 68 | 69 | for (( x=1; x<$m; x++ )) 70 | do 71 | ((days+=len[x])) 72 | done 73 | 74 | doy=$days 75 | 76 | if (( len[2] == 29 )) && (( doy >= 60 )); then 77 | ((--doy)) 78 | fi 79 | 80 | seasonday=$(( doy % 73 )) 81 | if (( seasonday == 0 )); then 82 | seasonday=73 83 | fi 84 | 85 | seasons=(Chaos Discord Confusion Bureaucracy "The Aftermath") 86 | case $doy in 87 | 73|146|219|291|365) 88 | season="${seasons[ $(( doy / 73)) - 1 ]}" ;; 89 | *) 90 | season="${seasons[ $(( doy / 73)) ]}" ;; 91 | esac 92 | } 93 | 94 | _discordian_array() 95 | { 96 | disc=() 97 | space=" " # 5 spaces 98 | case $season in 99 | Chaos) 100 | true 101 | ;; 102 | Discord) 103 | disc+=("$space" "$space" "$space") 104 | ;; 105 | Confusion) 106 | disc+=("$space") 107 | ;; 108 | Bureaucracy) 109 | disc+=("$space" "$space" "$space" "$space") 110 | ;; 111 | "The Aftermath") 112 | disc+=("$space" "$space" ) 113 | ;; 114 | esac 115 | 116 | for (( i=1; i<74; i++ )) 117 | do 118 | if (( i < 10 )); then 119 | if (( i == 5 )); then 120 | disc+=(" *5 ") 121 | else 122 | disc+=(" $i ") 123 | fi 124 | elif (( i == 50 )); then 125 | disc+=(" *50 ") 126 | else 127 | disc+=(" $i ") 128 | fi 129 | done 130 | } 131 | 132 | _print_discordian_calendar() 133 | { 134 | _discordian_date "$@" 135 | _discordian_array 136 | 137 | today=$d 138 | d=$seasonday 139 | case ${#d} in 140 | 1) 141 | d=" $d" 142 | ;; 143 | 2) 144 | d=" $d" 145 | ;; 146 | esac 147 | 148 | unset no_highlight 149 | if [ $tib ]; then 150 | no_highlight=1 151 | fi 152 | 153 | case $seasonday in 154 | 5) 155 | d="*5 " 156 | ;; 157 | 50) 158 | d="*50" 159 | ;; 160 | esac 161 | 162 | echo " $season $dy" 163 | echo " SM BT PD PP SO" 164 | 165 | for (( i=0; i<${#disc[@]}; i++ )) 166 | do 167 | if (( i % 5 == 0 )) && (( i != 0 )); then 168 | printf "\n" 169 | fi 170 | if [ "$d " = "${disc[i]}" ] || [ " $d " = "${disc[i]}" ] || [ " $d" = "${disc[i]}" ]; then 171 | printf "\e[7m%s\e[27m" "${disc[i]}" 172 | else 173 | printf "%s" "${disc[i]}" 174 | fi 175 | done 176 | echo 177 | } 178 | 179 | case $# in 180 | 1) 181 | m="$1" 182 | d="$(printf "%(%_d)T")" 183 | y="$(printf "%(%_Y)T")" 184 | ;; 185 | 2) 186 | m="$1" 187 | d="$(printf "%(%_d)T")" 188 | y="$2" 189 | ;; 190 | 3) 191 | m="$1" 192 | d="$2" 193 | y="$3" 194 | ;; 195 | *) 196 | m="$(printf "%(%_m)T")" 197 | d="$(printf "%(%_d)T")" 198 | y="$(printf "%(%_Y)T")" 199 | ;; 200 | esac 201 | 202 | _print_discordian_calendar $m $d $y 203 | -------------------------------------------------------------------------------- /dev/discordian/gd_conversion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | # 3 | # SCRIPT: gd_conversion.sh 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 06/17/2015-11:08:47 AM 6 | ######################################################################## 7 | # 8 | # gd_conversion.sh - Generate conversion chart 9 | # Copyright (C) 2015 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | export PATH=/bin:/usr/bin 27 | unalias -a 28 | 29 | _print_discordian_year() 30 | { 31 | [ $l -gt 0 ] || l=0 32 | 33 | for i in {1..73} 34 | do 35 | [ $l -eq 5 ] && l=0 && printf "\n" 36 | if [ $i -lt 10 ]; then 37 | if [ $i -eq 1 ]; then 38 | echo -n " ${SEASONS[s++]} $i" 39 | elif [ $i -eq 5 ]; then 40 | echo -n " *$i" 41 | else 42 | echo -n " $i" 43 | fi 44 | elif [ $i -eq 50 ]; then 45 | echo -n " *$i" 46 | else 47 | echo -n " $i" 48 | fi 49 | ((++l)) 50 | done 51 | } 52 | 53 | _print_gregorian_year() 54 | { 55 | [ $l -gt 0 ] || l=0 56 | 57 | for ((i=1; i<=${MONTH_LEN[$1-1]}; i++)) 58 | do 59 | [ $l -eq 5 ] && l=0 && printf "\n" 60 | if [ $i -lt 10 ]; then 61 | if [ $i -eq 1 ]; then 62 | echo -n " ${MONTHS[s++]} $i" 63 | else 64 | echo -n " $i" 65 | fi 66 | else 67 | echo -n " $i" 68 | fi 69 | ((++l)) 70 | done 71 | } 72 | 73 | _main() 74 | { 75 | if [ $(tput cols) -lt 77 ]; then 76 | echo The terminal is too small. This chart requires a terminal with 77 | echo at least 77 columns wide in order to view it properly. 78 | exit 1 79 | fi 80 | 81 | gyear=/tmp/gyear.$$ 82 | dyear=/tmp/dyear.$$ 83 | convert=gd_chart.txt 84 | 85 | SEASONS=(Chs Dsc Cfn Bcy Afm) 86 | MONTHS=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) 87 | MONTH_LEN=(31 28 31 30 31 30 31 31 30 31 30 31) 88 | 89 | l=0 s=0 90 | for n in {1..5} 91 | do 92 | _print_discordian_year 93 | done > $dyear 94 | 95 | l=0 s=0 96 | for n in {1..12} 97 | do 98 | _print_gregorian_year $n 99 | done > $gyear 100 | 101 | >$convert 102 | printf "\n\t\tGregorian\t\t\t\tDiscordian\n\n" >> $convert 103 | printf "\t\t\t\t\t SM BT PD PP SO\n" >> $convert 104 | printf " ------- ------- ------- -------\t" >> $convert 105 | printf " ------- ------- ------- -------\n" >> $convert 106 | 107 | paste $gyear $dyear >> $convert 108 | less $convert 109 | rm $gyear $dyear 110 | rm $convert 111 | } 112 | 113 | _main 114 | -------------------------------------------------------------------------------- /dev/discordian/gdj_conversion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | # 3 | # SCRIPT: gdj_conversion.sh 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 06/17/2015-11:08:47 AM 6 | ######################################################################## 7 | # 8 | # gdj_conversion.sh - Generate conversion chart 9 | # Copyright (C) 2015 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | export PATH=/bin:/usr/bin 27 | unalias -a 28 | 29 | _print_discordian_year() 30 | { 31 | [ $l -gt 0 ] || l=0 32 | 33 | for i in {1..73} 34 | do 35 | [ $l -eq 5 ] && l=0 && printf "\n" 36 | if [ $i -lt 10 ]; then 37 | if [ $i -eq 1 ]; then 38 | echo -n " ${SEASONS[s++]} $i" 39 | elif [ $i -eq 5 ]; then 40 | echo -n " *$i" 41 | else 42 | echo -n " $i" 43 | fi 44 | elif [ $i -eq 50 ]; then 45 | echo -n " *$i" 46 | else 47 | echo -n " $i" 48 | fi 49 | ((++l)) 50 | done 51 | } 52 | 53 | _print_gregorian_year() 54 | { 55 | [ $l -gt 0 ] || l=0 56 | 57 | for ((i=1; i<=${MONTH_LEN[$1-1]}; i++)) 58 | do 59 | [ $l -eq 5 ] && l=0 && printf "\n" 60 | if [ $i -lt 10 ]; then 61 | if [ $i -eq 1 ]; then 62 | echo -n " ${MONTHS[s++]} $i" 63 | else 64 | echo -n " $i" 65 | fi 66 | else 67 | echo -n " $i" 68 | fi 69 | ((++l)) 70 | done 71 | } 72 | 73 | _print_julian_year() 74 | { 75 | for i in {1..365} 76 | do 77 | [ $l -eq 5 ] && l=0 && printf "\n" 78 | if [ $i -lt 100 ] && [ $i -gt 9 ]; then 79 | case $i in 80 | 32|60|91) 81 | echo -n " ${MONTHS[s++]} $i " ;; 82 | 74) 83 | echo -n " ${SEASONS[q++]} $i " ;; 84 | 50|78) 85 | echo -n " *$i " ;; 86 | *) 87 | echo -n " $i " ;; 88 | esac 89 | elif [ $i -lt 10 ]; then 90 | case $i in 91 | 1) echo -n " ${MONTHS[s++]} $i " ;; 92 | 2) echo -n "${SEASONS[q++]} $i " ;; 93 | 5) echo -n " *$i " ;; 94 | *) echo -n " $i " ;; 95 | esac 96 | else 97 | case $i in 98 | 121|152|182|213|244|274|305|335) 99 | echo -n "${MONTHS[s++]} $i " ;; 100 | 123|151|196|224|269|297|342) 101 | echo -n " *$i " ;; 102 | 147|220|293) 103 | echo -n "${SEASONS[q++]} $i " ;; 104 | *) 105 | echo -n " $i " ;; 106 | esac 107 | fi 108 | ((++l)) 109 | done 110 | } 111 | 112 | _main() 113 | { 114 | if [ $(tput cols) -lt 120 ]; then 115 | echo The terminal is too small. This chart requires a terminal with 116 | echo at least 120 columns wide in order to view it properly. 117 | exit 1 118 | fi 119 | 120 | gyear=/tmp/gyear.$$ 121 | dyear=/tmp/dyear.$$ 122 | jyear=/tmp/jyear.$$ 123 | convert=gdj_chart.txt 124 | 125 | SEASONS=(Chs Dsc Cfn Bcy Afm) 126 | MONTHS=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) 127 | MONTH_LEN=(31 28 31 30 31 30 31 31 30 31 30 31) 128 | 129 | l=0 s=0 130 | for n in {1..5} 131 | do 132 | _print_discordian_year 133 | done > $dyear 134 | 135 | l=0 s=0 136 | for n in {1..12} 137 | do 138 | _print_gregorian_year $n 139 | done > $gyear 140 | 141 | l=0 s=0 q=0 142 | _print_julian_year >> $jyear 143 | 144 | >$convert 145 | printf "\n\t\tGregorian\t\t\t\tDiscordian\t\t\t\t Julian\n\n" >> $convert 146 | printf "\t\t\t\t\t SM BT PD PP SO\n" >> $convert 147 | printf " ------- ------- ------- -------\t" >> $convert 148 | printf " ------- ------- ------- -------\t" >> $convert 149 | printf " -------- -------- -------- --------\n" >> $convert 150 | 151 | paste $gyear $dyear $jyear >> $convert 152 | 153 | less $convert 154 | rm $gyear $dyear $jyear 155 | rm $convert 156 | } 157 | 158 | _main 159 | -------------------------------------------------------------------------------- /dev/hebrew/TODO.md: -------------------------------------------------------------------------------- 1 | # TODO for Hebrew 2 | 3 | ## Unfinished code. I have a bash version of this that works for most of the year -- but not for the first few months. 4 | -------------------------------------------------------------------------------- /dev/hebrew/hcal: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | REGULAR_HEBREW_MONTHS=(Tishrei Marcheshvan Kisleiv Teveis Shevat Adar 4 | Nissan Iyar Sivan Tammuz Av Elul) 5 | 6 | LEAP_HEBREW_MONTHS=(Tishrei Marcheshvan Kisleiv Teveis Shevat 7 | "Adar Rishon" Nissan Iyar Sivan Tammuz Av Elul "Adar Sheini") 8 | 9 | HEBREW_EPOC=-1373429 10 | 11 | CHALAKIM_IN_HOUR=1080 12 | HOURS_IN_DAY=24 13 | DAYS_IN_WEEK=7 14 | MINUTES_IN_HOUR=60 15 | CHALAKIM_IN_MINUTE=$((CHALAKIM_IN_HOUR / MINUTES_IN_HOUR)) 16 | 17 | _is_hebrew_leap_year() 18 | { 19 | if (( ((($1 * 7) + 1) % 19) < 7 )); then 20 | return 1 21 | else 22 | return 0 23 | fi 24 | 25 | } 26 | 27 | _last_hebrew_month() 28 | { 29 | _is_hebrew_leap_year $1 && echo 13 || echo 12 30 | } 31 | -------------------------------------------------------------------------------- /dev/hebrew/hebrew.rb: -------------------------------------------------------------------------------- 1 | 2 | # This module is not finished. 3 | 4 | module Hebrew 5 | 6 | def self.j_to_sdn(m, d, y) 7 | m, d, y = m.to_i, d.to_i, y.to_i 8 | 9 | if y == 0 || y < -4713 || m <=0 || m > 12 || m <= 0 || d > 31 10 | return(0) 11 | end 12 | 13 | if y == -4713 && m == 1 && m == 1 14 | return(0) 15 | end 16 | 17 | (y < 0) ? year = y + 4801 : year = y + 4800 18 | 19 | if m > 2 20 | month = m - 3 21 | else 22 | month = m + 9 23 | year -= 1 24 | end 25 | 26 | ((year * 1461) / 4) + ((month * 153 + 2) / 5) + (d - 32083) 27 | end 28 | 29 | def self.sdn_to_j(sdn, m, d, y) 30 | sdn, m, d, y = sdn.to_i, m.to_i, d.to_i, y.to_i 31 | 32 | if sdn <= 347997 33 | m, d, y = 0, 0, 0 34 | return 35 | end 36 | 37 | day = sdn - 347997 38 | 39 | # unfinished 40 | end 41 | 42 | def self.molad(mcycle) 43 | mcycle = mcycle.to_i 44 | 45 | r1 = 31524 46 | r1 += mcycle * (765433 & 65535) 47 | r2 = ri >> 16 48 | r2 += mcycle * (765433 >> 16) & 65535 49 | d2 = r2 / 25920 50 | r2 -= d2 * 25920 51 | r1 = (r2 << 16) | ( r1 & 65535) 52 | d1 = r1 / 25920 53 | r1 -= d1 * 25920 54 | 55 | moladday = (d1 << 16) | d1 56 | mhalakim = r1 57 | 58 | [ moladday, mhalakim ] 59 | end 60 | 61 | def self.tishri1(myear, mday, mhalakim) 62 | myear, mday, mhalakim = myear.to_i, mday.to_i, mhalakim.to_i 63 | 64 | tishri1 = mday 65 | dow = tishri1 % 7 66 | case myear 67 | when 2,5,7,10,13,16,18 then leap = myear 68 | end 69 | case myear 70 | when 3,6,8,11,14,17,0 then lastleap = myear 71 | end 72 | 73 | if mhalakim >= 101376 || ((!leap) && dow == 2 && mhalakim >= 229914) || 74 | (lastleap && dow == 1 && mhalakim >= 560269) 75 | tishri1 += 1 76 | dow += 1 77 | dow = 0 if dow == 7 78 | end 79 | 80 | case dow 81 | when 3,5,0 then tishri1 += 1 82 | end 83 | 84 | tishri1 85 | end 86 | 87 | end 88 | -------------------------------------------------------------------------------- /dev/lcal-python/CalendarData.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2.7 2 | 3 | import time 4 | import sys 5 | 6 | class CalendarData: 7 | 8 | monthNames = [0,"January","February","March","April","May","June","July", 9 | "August","September","October","November","December"] 10 | dayNames = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] 11 | 12 | def __init__(self,m,d,y): 13 | self.m = m 14 | self.d = d 15 | self.y = y 16 | 17 | def monthLen(self): 18 | if (self.y % 4 == 0) and (self.y % 100 != 0) or (self.y % 400 == 0): 19 | return ["",31,29,31,30,31,30,31,31,30,31,30,31] 20 | else: 21 | return ["",31,28,31,30,31,30,31,31,30,31,30,31] 22 | 23 | def dayOfWeek(self): 24 | mcodes = ["",6,2,2,5,0,3,5,1,4,6,2,4] 25 | w = ( ((self.y // 4) - (self.y // 100)) + (self.y // 400) + self.d + self.y + mcodes[self.m] ) 26 | 27 | mon = self.monthLen() 28 | if (mon[2] == 29) and ( self.m < 3): 29 | w-=1 30 | 31 | return (w % 7) 32 | 33 | def main(): 34 | 35 | if (len(sys.argv) == 4): 36 | month = int(sys.argv[1]) 37 | day = int(sys.argv[2]) 38 | year = int(sys.argv[3]) 39 | else: 40 | month = int(time.strftime("%m")) 41 | day = int(time.strftime("%d")) 42 | year = int(time.strftime("%Y")) 43 | 44 | cal = CalendarData(month,day,year) 45 | 46 | a = cal.dayOfWeek() 47 | 48 | print(cal.dayNames[a]) 49 | 50 | if __name__ == "__main__": 51 | main() 52 | -------------------------------------------------------------------------------- /dev/lcal-python/README.md: -------------------------------------------------------------------------------- 1 | # lcal-python 2 | 3 | ## Ideas on a python version of lcal 4 | -------------------------------------------------------------------------------- /dev/locale/README.md: -------------------------------------------------------------------------------- 1 | # locale 2 | 3 | ## Ideas on using a system's locale when generating calendar data. 4 | -------------------------------------------------------------------------------- /dev/locale/get_locale: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | short_weekdays=$(locale -c LC_TIME | sed -n '2p') 4 | long_weekdays=$(locale -c LC_TIME | sed -n '3p') 5 | 6 | short_months=$(locale -c LC_TIME | sed -n '4p') 7 | long_months=$(locale -c LC_TIME | sed -n '5p') 8 | 9 | unset gweek_header 10 | unset jweek_header 11 | unset DAYS 12 | unset MONTH_LIST 13 | unset LONG_MONTH_LIST 14 | 15 | OLDIFS="$IFS" 16 | IFS=";" 17 | 18 | for i in $short_weekdays; do gweek_header+=( "${i:0:2}" ); done 19 | for i in $short_weekdays; do jweek_header+=( "$i" ); done 20 | for i in $long_weekdays; do DAYS+=( "$i" ); done 21 | for i in $short_months; do MONTH_LIST+=( "$i" ); done 22 | for i in $long_months; do LONG_MONTH_LIST+=( "$i" ); done 23 | 24 | gweek_header="${gweek_header[@]}" 25 | jweek_header="${jweek_header[@]}" 26 | 27 | IFS="$OLDIFS" 28 | 29 | #config=lcal.locale 30 | 31 | { 32 | echo "DAYS=( ${DAYS[@]} )" 33 | echo "MONTH_LIST=( ${MONTH_LIST[@]} )" 34 | echo "LONG_MONTH_LIST=( ${LONG_MONTH_LIST[@]} )" 35 | echo "gweek_header=( $gweek_header )" 36 | echo "jweek_header=( $jweek_header )" 37 | } #> $config 38 | -------------------------------------------------------------------------------- /dev/perpetual-scripts/README.md: -------------------------------------------------------------------------------- 1 | # README for dev/perpetual-scripts 2 | 3 | These scripts were used in creating perpetual calendar arrays and strings. There are no bugs that I know of. I'll keep these files here for future reference. 4 | -------------------------------------------------------------------------------- /dev/perpetual-scripts/leap-cycle.txt: -------------------------------------------------------------------------------- 1 | 1928 2 | 1940 3 | 1952 4 | 1964 5 | 1976 6 | 1988 7 | 2000 8 | -------------------------------------------------------------------------------- /dev/perpetual-scripts/leap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | _is_leap() 4 | { 5 | local y=$1 6 | if [ $((y % 4)) -eq 0 ] && 7 | [ $((y % 100)) -ne 0 ] || 8 | [ $((y % 400)) -eq 0 ]; then 9 | return 0 10 | else 11 | return 1 12 | fi 13 | } 14 | 15 | days=(Sunday Monday Tuesday Wednesday Thursday Friday Saturday) 16 | 17 | n=0 18 | for i in {1900..2000} 19 | do 20 | _is_leap $i || { continue ; ((n++)); } 21 | 22 | if [ "$(lcal -d 1 1 $i)" = "${days[n]}" ]; then 23 | echo $i 24 | ((n++)) 25 | fi 26 | done 27 | -------------------------------------------------------------------------------- /dev/perpetual-scripts/matrix: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | _month_len() 4 | { 5 | local m=$1 y=$2 6 | case $m in 7 | 4|6|9|11) 8 | echo 30 9 | ;; 10 | 1|3|5|7|8|10|12) 11 | echo 31 12 | ;; 13 | 2) 14 | _is_leap $y 15 | if [ $LEAP ] ; then 16 | echo 29 17 | else 18 | echo 28 19 | fi 20 | ;; 21 | esac 22 | } 23 | 24 | _is_leap() 25 | { 26 | local y=$1 27 | unset LEAP 28 | if [ $((y % 4)) -eq 0 ] && 29 | [ $((y % 100)) -ne 0 ] || 30 | [ $((y % 400)) -eq 0 ]; then 31 | LEAP=1 32 | fi 33 | } 34 | 35 | _day_of_week() 36 | { 37 | local m=$1 d=$2 y=$3 38 | 39 | local mcodes=(UNUSED 6 2 2 5 0 3 5 1 4 6 2 4) 40 | local w=$(( ((y / 4) - (y / 100)) + (y / 400) + d + y + ${mcodes[m]} )) 41 | 42 | _is_leap $y 43 | if [ $LEAP ] && [ $m -lt 3 ]; then 44 | ((w--)) 45 | fi 46 | 47 | echo $((w % 7)) 48 | } 49 | 50 | _gregorian_array_matrix() 51 | { 52 | CALENDAR_DATA=() 53 | local m=$1 y=$2 54 | first_day_number_of_month=$(_day_of_week $m 1 $y) 55 | local len=$(_month_len $m $y) 56 | 57 | for ((i=1 ; i<=first_day_number_of_month; i++)); do 58 | if [ $first_day_number_of_month -eq 0 ]; then 59 | break 60 | fi 61 | CALENDAR_DATA+=(" ") 62 | done 63 | 64 | # for ((i=1; i<=42; i++)); do 65 | for ((i=1; i<=$((60 - first_day_number_of_month)); i++)); do 66 | if [ $i -lt 10 ]; then 67 | CALENDAR_DATA+=(" $i") 68 | elif [ $i -gt $len ]; then 69 | CALENDAR_DATA+=(" ") 70 | else 71 | CALENDAR_DATA+=($i) 72 | fi 73 | done 74 | } 75 | 76 | _print_gregorian_string() 77 | { 78 | local m=$1 d=$2 y=$3 79 | 80 | _gregorian_array_matrix $m $y 81 | 82 | for ((i=0; i<${#CALENDAR_DATA[@]}-7; i++)); do 83 | echo -n "${CALENDAR_DATA[i]} " 84 | done 85 | 86 | echo 87 | } 88 | 89 | _print_gregorian_string_yearly() 90 | { 91 | local m=$1 d=$2 y=$3 92 | 93 | for n in {1..12} 94 | do 95 | echo "\"$(_print_gregorian_string $n $d $y)\"" 96 | done 97 | } 98 | 99 | leap_cycle=( leap_cycle{0..6} ) 100 | non_leap_cycle=( non_leap_cycle{0..6} ) 101 | 102 | >arrays 103 | 104 | t=0 105 | for x in 1905 1906 1907 1913 1914 1915 1921 106 | do 107 | echo "${non_leap_cycle[t]}=(" 108 | _print_gregorian_string_yearly 1 1 $x 109 | echo ")" 110 | ((++t)) 111 | done >> arrays 112 | 113 | t=0 114 | for x in 1928 1940 1952 1964 1976 1988 2000 115 | do 116 | echo "${leap_cycle[t]}=(" 117 | _print_gregorian_string_yearly 1 1 $x 118 | echo ")" 119 | ((++t)) 120 | done >> arrays 121 | 122 | -------------------------------------------------------------------------------- /dev/perpetual-scripts/non-leap-cycle.txt: -------------------------------------------------------------------------------- 1 | 1905 2 | 1906 3 | 1907 4 | 1913 5 | 1914 6 | 1915 7 | 1921 8 | -------------------------------------------------------------------------------- /dev/perpetual-scripts/non-leap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | _is_leap() 4 | { 5 | local y=$1 6 | if [ $((y % 4)) -eq 0 ] && 7 | [ $((y % 100)) -ne 0 ] || 8 | [ $((y % 400)) -eq 0 ]; then 9 | return 1 10 | fi 11 | } 12 | 13 | days=(Sunday Monday Tuesday Wednesday Thursday Friday Saturday) 14 | 15 | n=0 16 | for i in {1900..1960} 17 | do 18 | _is_leap $i || continue 19 | 20 | if [ "$(lcal -d 1 1 $i)" = "${days[n]}" ]; then 21 | echo $i 22 | ((n++)) 23 | fi 24 | done 25 | -------------------------------------------------------------------------------- /dev/perpetual-scripts/string-matrix: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | _month_len() 4 | { 5 | local m=$1 y=$2 6 | case $m in 7 | 4|6|9|11) 8 | echo 30 9 | ;; 10 | 1|3|5|7|8|10|12) 11 | echo 31 12 | ;; 13 | 2) 14 | _is_leap $y 15 | if [ $LEAP ] ; then 16 | echo 29 17 | else 18 | echo 28 19 | fi 20 | ;; 21 | esac 22 | } 23 | 24 | _is_leap() 25 | { 26 | local y=$1 27 | unset LEAP 28 | if [ $((y % 4)) -eq 0 ] && 29 | [ $((y % 100)) -ne 0 ] || 30 | [ $((y % 400)) -eq 0 ]; then 31 | LEAP=1 32 | fi 33 | } 34 | 35 | _day_of_week() 36 | { 37 | local m=$1 d=$2 y=$3 38 | 39 | local mcodes=(UNUSED 6 2 2 5 0 3 5 1 4 6 2 4) 40 | local w=$(( ((y / 4) - (y / 100)) + (y / 400) + d + y + ${mcodes[m]} )) 41 | 42 | _is_leap $y 43 | if [ $LEAP ] && [ $m -lt 3 ]; then 44 | ((w--)) 45 | fi 46 | 47 | echo $((w % 7)) 48 | } 49 | 50 | _gregorian_array_matrix() 51 | { 52 | CALENDAR_DATA=() 53 | local m=$1 y=$2 54 | first_day_number_of_month=$(_day_of_week $m 1 $y) 55 | local len=$(_month_len $m $y) 56 | 57 | for ((i=1 ; i<=first_day_number_of_month; i++)); do 58 | if [ $first_day_number_of_month -eq 0 ]; then 59 | break 60 | fi 61 | CALENDAR_DATA+=(" ") 62 | done 63 | 64 | # for ((i=1; i<=42; i++)); do 65 | for ((i=1; i<=$((60 - first_day_number_of_month)); i++)); do 66 | if [ $i -lt 10 ]; then 67 | CALENDAR_DATA+=(" $i") 68 | elif [ $i -gt $len ]; then 69 | CALENDAR_DATA+=("") 70 | else 71 | CALENDAR_DATA+=($i) 72 | fi 73 | done 74 | } 75 | 76 | _print_gregorian_string() 77 | { 78 | local m=$1 d=$2 y=$3 79 | 80 | _gregorian_array_matrix $m $y 81 | 82 | for ((i=0; i<${#CALENDAR_DATA[@]}-7; i++)); do 83 | echo -n "${CALENDAR_DATA[i]} " 84 | done 85 | 86 | echo 87 | } 88 | 89 | _print_gregorian_string_yearly() 90 | { 91 | local m=$1 d=$2 y=$3 92 | local cycle=$4 93 | 94 | for n in {1..12} 95 | do 96 | echo "${cycle}_${n}=\"$(_print_gregorian_string $n $d $y)\"" 97 | done 98 | } 99 | 100 | leap_cycle=( leap_cycle_{0..6} ) 101 | non_leap_cycle=( non_leap_cycle_{0..6} ) 102 | 103 | file=perpetual-strings.txt 104 | >$file 105 | 106 | t=0 107 | for x in 1905 1906 1907 1913 1914 1915 1921 108 | do 109 | if [ "${non_leap_cycle[t]}" = "$t" ]; then 110 | echo "${non_leap_cycle[t]}_${t}=\"" 111 | fi 112 | _print_gregorian_string_yearly 1 1 $x ${non_leap_cycle[t]} 113 | echo 114 | ((++t)) 115 | done >> $file 116 | 117 | t=0 118 | for x in 1928 1940 1952 1964 1976 1988 2000 119 | do 120 | if [ "${leap_cycle[t]}" = "$t" ]; then 121 | echo "${leap_cycle[t]}_${t}=\"" 122 | fi 123 | _print_gregorian_string_yearly 1 1 $x ${leap_cycle[t]} 124 | echo 125 | ((++t)) 126 | done >> $file 127 | -------------------------------------------------------------------------------- /dev/reformation/README.md: -------------------------------------------------------------------------------- 1 | # README for reformation 2 | 3 | These development files are an attempt to integrate the Gregorian Reformation into **lcal**. Changes include a new day of week algorithm, a pre 1753 leap year function and a few helper functions for counting centuries and leap years. These additions have an overall impact on the program. month_array replaces month_len and month lengths are requested by len[m]. month_array should only be called once per program execution. 4 | 5 | The only drawback I can see so far is that **lcal** is much slower with these additions. _lcal.dev_ will stay here until I can improve on its poor performance. 6 | -------------------------------------------------------------------------------- /dev/reformation/sept1752: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | SEPT1752=" 4 | September 1752 5 | Su Mo Tu We Th Fr Sa 6 | 1 2 14 15 16 7 | 17 18 19 20 21 22 23 8 | 24 25 26 27 28 29 30 9 | 10 | 11 | 12 | " 13 | -------------------------------------------------------------------------------- /dev/shcal: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | # 3 | # SCRIPT: shcal 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 10/21/2017-01:56:43 AM 6 | ######################################################################## 7 | # 8 | # shcal - display a calendar - POSIX version 9 | # Copyright (C) 2017 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | export PATH=/bin:/usr/bin 27 | unalias -a 28 | PROGRAM="${0##*/}" 29 | 30 | month_names_long="January February March April May June July August September October November December" 31 | month_names_short="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" 32 | day_names_short="Su Mo Tu We Thu Fr Sa" 33 | 34 | month=$(date +%m) 35 | day=$(date +%d) 36 | year=$(date +%Y) 37 | 38 | _get_month() 39 | { 40 | local c=0 41 | for i in $month_names_long 42 | do 43 | c=$(($c + 1)) 44 | if [ $c -eq $1 ]; then 45 | echo "$i" 46 | return 47 | fi 48 | done 49 | } 50 | 51 | _get_month_lengths() 52 | { 53 | if [ $(($1 % 4)) -eq 0 ] && [ $(($1 % 100)) -ne 0 ] || [ $(($1 % 400)) -eq 0 ]; then 54 | len="31 29 31 30 31 30 31 31 30 31 30 31" 55 | else 56 | len="31 28 31 30 31 30 31 31 30 31 30 31" 57 | fi 58 | } 59 | 60 | _is_leap() 61 | { 62 | if [ $(($1 % 4)) -eq 0 ] && [ $(($1 % 100)) -ne 0 ] || [ $(($1 % 400)) -eq 0 ]; then 63 | return 1 64 | fi 65 | } 66 | 67 | _month_len() 68 | { 69 | local c=0 70 | for i in $len 71 | do 72 | c=$(($c + 1)) 73 | if [ $c -eq $1 ]; then 74 | mlen="$i" 75 | fi 76 | done 77 | } 78 | 79 | _center() 80 | { 81 | printf "%*s\n" $(( (${1} + ${#2}) / 2 )) "$2" 82 | } 83 | 84 | _ncenter() 85 | { 86 | printf "%*s" $(( (${1} + ${#2}) / 2)) "$2" 87 | } 88 | 89 | _is_day_valid() 90 | { 91 | if [ $1 -gt $mlen ] || [ $1 -le 0 ]; then 92 | echo "$PROGRAM: day out of range of month [1-${mlen}]" 93 | return 1 94 | fi 95 | } 96 | 97 | _is_month_valid() 98 | { 99 | if [ $1 -gt 12 ] || [ $1 -lt 1 ]; then 100 | echo "$PROGRAM: month out of range [1-12]" 101 | return 1 102 | fi 103 | } 104 | -------------------------------------------------------------------------------- /docs/documentation.md: -------------------------------------------------------------------------------- 1 | 2 | # Function documentation manual for ../bin/lcal 3 | 4 | 5 | Function: **_main** 6 | 7 | Parameters: *flags parameters* 8 | 9 | This function is the starting point of lcal. It processes 10 | 11 | all values and flags passed on the command-line and forwards them 12 | 13 | to the appropriate function calls. 14 | 15 | Function: **_is_year_valid** 16 | 17 | Parameters: *year* 18 | 19 | return 1 if year is not in range. 20 | 21 | Function: **_is_month_valid** 22 | 23 | Parameters: *month* 24 | 25 | return 1 if month is not in range. 26 | 27 | Function: **_is_day_valid** 28 | 29 | Parameters: *month day year* 30 | 31 | return 1 if day is not in range of month 32 | 33 | in the specified year. 34 | 35 | Function: **_is_date_valid** 36 | 37 | Parameters: *month day year* 38 | 39 | This function should be called before any other. 40 | 41 | It checks if months, days or years are within valid limits - 42 | 43 | i.e. 13 1 2000, etc. Return 1 if date is invalid. If no 44 | 45 | date is passed to this function, skip it; the default date 46 | 47 | is used. 48 | 49 | Function: **_parse_month** 50 | 51 | Parameters: *month* 52 | 53 | return month number [1-12] if month was 54 | 55 | typed as a name. Stop reading after third character. 56 | 57 | Return 255 if not found. 58 | 59 | Function: **_month_len** 60 | 61 | Parameters: *month year* 62 | 63 | Print the length of the month. Calls 64 | 65 | _isleap in the case of February. 66 | 67 | Function: **_is_leap** 68 | 69 | Parameters: *year* 70 | 71 | Loads the LEAP variable if year is a leap year. 72 | 73 | Function: **_day_of_week** 74 | 75 | Parameters: *month day year* 76 | 77 | Print the day number for date. 0 = Sunday, etc. 78 | 79 | Function: **_gregorian_array** 80 | 81 | Parameters: *month year* 82 | 83 | Loads the CALENDAR_DATA array with correctly 84 | 85 | spaced numbers for later printing. 86 | 87 | Function: **_print_gregorian_monthly** 88 | 89 | Parameters: *month day year* 90 | 91 | Print the Gregorian calendar for date. 92 | 93 | To prevent highlighting, set the day value to 0. 94 | 95 | Function: **_julian_array** 96 | 97 | Parameters: *month day year* 98 | 99 | Loads the CALENDAR_DATA array with correctly 100 | 101 | spaced numbers for later printing. 102 | 103 | Function: **_print_julian_monthly** 104 | 105 | Parameters: *month day year* 106 | 107 | Print the Julian calendar for date. 108 | 109 | To prevent highlighting, set the day value to 0. 110 | 111 | Function: **_center** 112 | 113 | Parameters: *length "string"* 114 | 115 | Center a line of text in a specified width. 116 | 117 | The string must be quoted. 118 | 119 | Function: **_ncenter** 120 | 121 | Parameters: *length "string"* 122 | 123 | Center a line of text in a specified width. 124 | 125 | No new line is added at the end. The string must be quoted. 126 | 127 | Function: **_shift_month_forward** 128 | 129 | Parameters: *month* 130 | 131 | Moves the month number up by one, or back to one 132 | 133 | if the current month is December. 134 | 135 | Function: **_shift_month_backward** 136 | 137 | Parameters: *month* 138 | 139 | Moves the month number back by one, or up to twelve 140 | 141 | if the current month is January. 142 | 143 | Function: **_day_in_year** 144 | 145 | Parameters: *day month year* 146 | 147 | Get the one-based number for date. Day 1 starts 148 | 149 | on January 1, day 365 is December 31. 150 | 151 | Function: **_jdn_to_gregorian_date** 152 | 153 | Parameters: *jdn* 154 | 155 | Convert a Julian day number into month, day and 156 | 157 | year in Gregorian notation. gday, gmonth, gyear are loaded. 158 | 159 | Function: **_gregorian_date_to_jdn** 160 | 161 | Parameters: *month day year* 162 | 163 | Convert Gregorian month, day and year into the 164 | 165 | Julian day number. 166 | 167 | Function: **_print_ncal_gregorian** 168 | 169 | Parameters: *month day year* 170 | 171 | Print the Gregorian calendar for date in ncal 172 | 173 | format. To prevent highlighting, set the day value to 0. 174 | 175 | Function: **_ncal_array** 176 | 177 | Parameters: *month day year* 178 | 179 | Loads the NCAL array with correctly 180 | 181 | spaced numbers for printing the Julian calendar 182 | 183 | in the ncal format. 184 | 185 | Function: **_print_ncal_julian** 186 | 187 | Parameters: *month day year* 188 | 189 | Print the Julian calendar for date in ncal 190 | 191 | format. To prevent highlighting, set the day value to 0. 192 | 193 | Function: **_show_week_numbers** 194 | 195 | Parameters: *month day year* 196 | 197 | print week numbers next to the Gregorian calendar. 198 | 199 | Function: **_ordinal** 200 | 201 | Parameters: *number* 202 | 203 | Print the ordinal of a number: 1st, 2nd, 3rd, etc. 204 | 205 | Function: **_show_discordian_date** 206 | 207 | Parameters: *month day year* 208 | 209 | Print a date according to the Discordian calendar. 210 | 211 | Feb 29th of a leap year is St. Tibbs day, which is a day 212 | 213 | that doesn't exist! 214 | 215 | Function: **_print_gregorian_yearly** 216 | 217 | Parameters: *year* 218 | 219 | Print the formatted yearly calendar for year. 220 | 221 | Function: **_print_gregorian_three_months** 222 | 223 | Parameters: *none* 224 | 225 | Print last, current and next month on one row. 226 | 227 | Function: **_week_number** 228 | 229 | Parameters: *month day year* 230 | 231 | Return week-number of date. If the week-number 232 | 233 | is 0, return the last week-number of last year. 234 | 235 | Function: **_western_pfm_date** 236 | 237 | Parameters: *year* 238 | 239 | Find the day number and month of the Paschal Full Moon. 240 | 241 | Function: **_orthodox_pfm_date_2** 242 | 243 | Parameters: *year* 244 | 245 | Find the day number and month of the Paschal Full Moon. 246 | 247 | This is the second chart. 248 | 249 | Function: **_western_first_2** 250 | 251 | Parameters: *year* 252 | 253 | Use the first two digits of year to 254 | 255 | find the cooresponding number on the chart. 256 | 257 | Function: **_orthodox_western_last_2** 258 | 259 | Parameters: *year* 260 | 261 | Use the last two digits of year to 262 | 263 | find the cooresponding number on the chart. 264 | 265 | Function: **_show_western_easter** 266 | 267 | Parameters: *year* 268 | 269 | Find the date of Easter according to the Gregorian calendar. 270 | 271 | Function: **_orthodox_first_2** 272 | 273 | Parameters: *year* 274 | 275 | Use the first two digits of year to 276 | 277 | find the cooresponding number on the chart. 278 | 279 | Function: **_orthodox_pfm_date** 280 | 281 | Parameters: *year* 282 | 283 | Find the day number and month of the Paschal Full Moon. 284 | 285 | Function: **_orthodox_pfm_date_2** 286 | 287 | Parameters: *year* 288 | 289 | Find the day number and month of the Paschal Full Moon. 290 | 291 | This is the second chart. 292 | 293 | Function: **_convert_to_gregorian** 294 | 295 | Parameters: *year* 296 | 297 | convert a Julian year to a Gregorian year. 298 | 299 | This corrects the Julian "drift." 300 | 301 | Function: **_show_orthodox_easter** 302 | 303 | Parameters: *year* 304 | 305 | Find the date of Easter according to the Eastern Orthodox calendar. 306 | 307 | if REQUEST_JULIAN is set, the date is converted to the Julian date. 308 | 309 | Function: **_show_html_calendar** 310 | 311 | Parameters: *month day year* 312 | 313 | Generate raw html of the specified calendar. A CSS 314 | 315 | script is loaded into the css variable. Styling should be 316 | 317 | changed from there. 318 | 319 | Function: **_date_diff** 320 | 321 | Parameters: *month day year month day year* 322 | 323 | Show the time difference between two dates. 324 | 325 | 3 parameters: compute today's date against specified date. 326 | 327 | 6 parameters: computer one date against the other. 328 | 329 | Function: **_exit** 330 | 331 | Parameters: *exit-status* 332 | 333 | Clean up the terminal and exit according 334 | 335 | to an exit status. If invalid flags or parameters 336 | 337 | were passed, use `_exit 1`, otherwise use `_exit 0`. 338 | -------------------------------------------------------------------------------- /docs/lcal-doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 |
Functions for ../bin/lcalLine NumberParameters 6 |
_main105flags parameters
_is_year_valid433year
_is_month_valid449month
_is_day_valid460month day year
_is_date_valid475month day year
_parse_month542month
_month_len565month year
_is_leap588year
_day_of_week601month day year
_gregorian_array619month year
_print_gregorian_monthly647month day year
_julian_array683month day year
_print_julian_monthly716month day year
_center754length "string"
_ncenter762length "string"
_shift_month_forward771month year
_shift_month_backward786month year
_day_in_year801day month year
_jdn_to_gregorian_date814jdn
_gregorian_date_to_jdn835month day year
_print_ncal_gregorian849month day year
_ncal_array890month day year
_print_ncal_julian921month day year
_show_week_numbers965month day year
_ordinal1020number
_show_discordian_date1034month day year
_print_gregorian_yearly1092year
_print_gregorian_three_months1148_print_gregorian_three_months
_week_number1195month day year
_western_pfm_date1232year
_western_pfm_date_21263year
_western_first_21280year
_orthodox_western_last_21297year
_show_western_easter1313year
_orthodox_first_21363year
_orthodox_pfm_date1379year
_orthodox_pfm_date_21410year
_convert_to_gregorian1427year
_show_orthodox_easter1450year
_show_html_calendar1513month day year
_date_diff1690month day year month day year
_exit1741exit-status
218 | -------------------------------------------------------------------------------- /docs/lcal.1.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | lcal man page 5 | 6 | 46 | 47 | 48 |

49 |

NAME

50 |

lcal - display a calendar. 51 |

SYNOPSIS

52 |

lcal [options] [month] [day] [year] 53 |

54 |

DESCRIPTION

55 |

lcal is a command-line calendar similar to cal and ncal. 56 |

OPTIONS

57 |

58 |

-d --day-of-week 59 |

Show day-name for date. 60 |

-e --easter 61 |

Show the date for Easter (Western). 62 |

-h --no-highlight 63 |

Disable highlighting. 64 |

-j --julian 65 |

Show Julian calendar. Days are one based - Dec 31st is day 365 (or 366 if year is a leap year). 66 |

-m --month 67 |

Show calendar for month. A year may be the next parameter. 68 |

-n --next 69 |

Show next month's calendar. 70 |

-o --orthodox 71 |

Show the date for Easter (Eastern Orthodox). 72 |

-p --previous 73 |

Show last month's calendar. 74 |

-w --week-number 75 |

Show week number. 76 |

-x --date-diff 77 |

Show time between two dates. This option takes either 3 parameters or 6, as in MM DD YYYY MM DD YYYY or MM DD YYYY. If three, the current date is computed against it; if six, one date is computed against the other. 78 |

-y --year 79 |

Show yearly calendar. 80 |

-D --discordian 81 |

Show date according to the Disordian calendar. 82 |

-G --gregorian-to-jdn 83 |

Convert a Gregorian date to the Julian Day Number (jdn). 84 |

-H --html 85 |

Generate an HTML calendar. Use -h --html to turn off highlighting. Output must be redirected to a file. 86 |

-J --jdn-to-gregorian 87 |

Convert a Julian Day Number (jdn) to Gregorian. 88 |

-N --ncal 89 |

Show the calendar in ncal format. 90 |

-O --orthodox-julian 91 |

Show the date for Orthodox Easter according the the Julian Calendar. 92 |

-V --version 93 |

Show version information. 94 |

-W --show-week-numbers 95 |

Show week numbers next to default calendar. 96 |

-1 --one 97 |

Show only the current calendar. This is the default. 98 |

-3 --three 99 |

Show last month, this month and next month. 100 |

--help 101 |

Show usage information. 102 |

PARAMETERS

103 |

Most flags can take a date string as an argument. A single parameter is either a month -- this will print the month for the current year -- or it is a year -- this will print the yearly calendarfor the specified year. Two parameters are month and year -- this will print the month for the specified year. Three parameters are month , day and year -- this will print the specified calendar with the day highlighted. 104 |

month can be numbers [ 1-12 ], or three or more letters of the month name: jan , feb , mar , etc. 105 |

The year range is currently 1753 - 9999 106 |

107 |

The -m flag is the same as month without the flag. A year can be added after month 108 |

109 |

To disable highlighting for --html , use -h before this flag. 110 |

Flags -1 , -n and -p stop reading arguments after them. 111 |

AUTHOR

112 |

The utility lcal and this manual were written by Luciano D. Cecere 113 |

LICENSE

114 |

Copyright (C) 2014-2016 Luciano D. Cecere <Ldante86@aol.com> 115 |

Released under the terms of the GNU General Public License, version 2 116 |

This is free software; see the source for copying conditions. There is NO warranty, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 117 |

SEE ALSO

118 |

cal(1), ddate(1), ncal(1), gcal(1)

119 | This HTML page was made with roffit. 120 | 121 | -------------------------------------------------------------------------------- /docs/plcal.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

23 | 24 |

NAME

25 | 26 |

plcal - Display a monthly calendar

27 | 28 |

SYNOPSIS

29 | 30 |
        plcal [option]
 31 |         plcal --help
32 | 33 |

DESCRIPTION

34 | 35 |
        plcal is a simple command-line calendar written in perl.
36 | 37 |

OPTIONS

38 | 39 |
40 | 41 |
-b
42 |
43 | 44 |

Use bracketed bolding (<>).

45 | 46 |
47 |
-h
48 |
49 | 50 |

Disable highlighting.

51 | 52 |
53 |
-n
54 |
55 | 56 |

Show next nomth.

57 | 58 |
59 |
-p
60 |
61 | 62 |

Show previous month.

63 | 64 |
65 |
--help
66 |
67 | 68 |

Display a help text and exit.

69 | 70 |
71 |
--date=mm yyyy
72 |
73 | 74 |

Display a calendar for a specified month and year.

75 | 76 |
77 |
--month=mm
78 |
79 | 80 |

Show specified month in current year.

81 | 82 |
83 |
84 | 85 |

NOTES

86 | 87 |

The -b option will be the default if the OS is Windows.

88 | 89 |

AUTHOR

90 | 91 |

Luciano D. Cecere <ldante1986@gmail.com>

92 | 93 |

LICENSE

94 | 95 |

plcal is free software; you can redistribute it and/or modify it under the terms of the GPL, or, optionally, Perl's license.

96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /man/install_man: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | 3 | MANLOC=/usr/share/man/man 4 | 5 | #set -- lcal.1 6 | 7 | MANPAGE="$1" 8 | SECTION=${2:-1} 9 | 10 | unset GZIP 11 | 12 | case $MANPAGE in 13 | *.[1-9]) 14 | GZIP=1 15 | ;; 16 | *.[1-9].gz) 17 | true 18 | ;; 19 | '') 20 | echo no file given 21 | exit 1 22 | ;; 23 | *) 24 | echo cannot install that manual 25 | exit 1 26 | ;; 27 | esac 28 | 29 | case $SECTION in 30 | [1-9]) 31 | true 32 | ;; 33 | *) 34 | echo not a correct section number 35 | exit 1 36 | ;; 37 | esac 38 | 39 | if [ ! -e $MANPAGE ]; then 40 | echo $MANPAGE does not exist 41 | exit 1 42 | fi 43 | 44 | if [ $GZIP ]; then 45 | /bin/gzip $MANPAGE 46 | sudo cp ${MANPAGE}.gz ${MANLOC}${SECTION} 47 | /bin/gunzip ${MANPAGE}.gz 48 | else 49 | sudo cp ${MANPAGE} ${MANLOC}${SECTION} 50 | /bin/gunzip ${MANPAGE} 51 | fi 52 | 53 | echo "...complete - to access use: man ${MANPAGE%.*}" 54 | -------------------------------------------------------------------------------- /man/lcal.1: -------------------------------------------------------------------------------- 1 | .TH lcal 1 "2016" "" "lcal " 2 | 3 | .SH NAME 4 | lcal \- display a calendar. 5 | 6 | .SH SYNOPSIS 7 | .B lcal 8 | [options] [month] [day] [year] 9 | .br 10 | 11 | .SH DESCRIPTION 12 | .B lcal 13 | is a command-line calendar similar to 14 | .B cal 15 | and 16 | .B ncal. 17 | 18 | .SH OPTIONS 19 | .B 20 | .IP "-d --day-of-week" 21 | Show day-name for date. 22 | .B 23 | .IP "-e --easter" 24 | Show the date for Easter (Western). 25 | .B 26 | .IP "-h --no-highlight" 27 | Disable highlighting. 28 | .B 29 | .IP "-j --julian" 30 | Show Julian calendar. Days are one based - Dec 31st is day 365 (or 366 if year is a leap year). 31 | .B 32 | .IP "-m --month" 33 | Show calendar for month. A year may be the next parameter. 34 | .B 35 | .IP "-n --next" 36 | Show next month's calendar. 37 | .B 38 | .IP "-o --orthodox" 39 | Show the date for Easter (Eastern Orthodox). 40 | .B 41 | .IP "-p --previous" 42 | Show last month's calendar. 43 | .B 44 | .IP "-w --week-number" 45 | Show week number. 46 | .B 47 | .IP "-x --date-diff" 48 | Show time between two dates. This option takes either 3 parameters or 6, as in MM DD YYYY MM DD YYYY or MM DD YYYY. If three, the current date is computed against it; if six, one date is computed against the other. 49 | .B 50 | .IP "-y --year" 51 | Show yearly calendar. 52 | .B 53 | .IP "-D --discordian" 54 | Show date according to the Disordian calendar. 55 | .B 56 | .IP "-G --gregorian-to-jdn" 57 | Convert a Gregorian date to the Julian Day Number (jdn). 58 | .B 59 | .IP "-H --html" 60 | Generate an HTML calendar. Use 61 | .B -h --html 62 | to turn off highlighting. Output must be redirected to a file. 63 | .B 64 | .IP "-J --jdn-to-gregorian" 65 | Convert a Julian Day Number (jdn) to Gregorian. 66 | .B 67 | .IP "-N --ncal" 68 | Show the calendar in 69 | .B ncal 70 | format. 71 | .B 72 | .IP "-O --orthodox-julian" 73 | Show the date for Orthodox Easter according the the Julian Calendar. 74 | .B 75 | .IP "-V --version" 76 | Show version information. 77 | .B 78 | .IP "-W --show-week-numbers 79 | Show week numbers next to default calendar. 80 | .B 81 | .IP "-1 --one" 82 | Show only the current calendar. This is the default. 83 | .B 84 | .IP "-3 --three" 85 | Show last month, this month and next month. 86 | .B 87 | .IP "--help" 88 | Show usage information. 89 | 90 | .SH PARAMETERS 91 | Most flags can take a date string as an argument. A single parameter is either a 92 | .B month 93 | -- this will print the month for the current year -- or it is a 94 | .B year 95 | -- this will print the yearly calendarfor the specified year. Two parameters are 96 | .B month 97 | and 98 | .B year 99 | -- this will print the month for the specified year. Three parameters are 100 | .B month 101 | , 102 | .B day 103 | and 104 | .B year 105 | -- this will print the specified calendar with the day highlighted. 106 | 107 | .B month 108 | can be numbers [ 109 | .B 1-12 110 | ], or three or more letters of the month name: 111 | .B jan 112 | , 113 | .B feb 114 | , 115 | .B mar 116 | , etc. 117 | 118 | The year range is currently 119 | .B 1753 - 9999 120 | . 121 | 122 | The 123 | .B -m 124 | flag is the same as 125 | .B month 126 | without the flag. A 127 | .B year 128 | can be added after 129 | .B month 130 | . 131 | 132 | To disable highlighting for 133 | .B --html 134 | , use 135 | .B -h 136 | before this flag. 137 | 138 | Flags 139 | .B -1 140 | , 141 | .B -n 142 | and 143 | .B -p 144 | stop reading arguments after them. 145 | 146 | .SH AUTHOR 147 | The utility lcal and this manual were written by Luciano D. Cecere 148 | 149 | .SH LICENSE 150 | Copyright (C) 2014-2016 Luciano D. Cecere 151 | 152 | Released under the terms of the GNU General Public License, version 2 153 | 154 | This is free software; see the source for copying conditions. 155 | There is NO warranty, without even the implied warranty of 156 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 157 | 158 | .SH "SEE ALSO" 159 | .B cal(1), ddate(1), ncal(1), gcal(1) 160 | -------------------------------------------------------------------------------- /man/plcal.1: -------------------------------------------------------------------------------- 1 | .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) 2 | .\" 3 | .\" Standard preamble: 4 | .\" ======================================================================== 5 | .de Sp \" Vertical space (when we can't use .PP) 6 | .if t .sp .5v 7 | .if n .sp 8 | .. 9 | .de Vb \" Begin verbatim text 10 | .ft CW 11 | .nf 12 | .ne \\$1 13 | .. 14 | .de Ve \" End verbatim text 15 | .ft R 16 | .fi 17 | .. 18 | .\" Set up some character translations and predefined strings. \*(-- will 19 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left 20 | .\" double quote, and \*(R" will give a right double quote. \*(C+ will 21 | .\" give a nicer C++. Capital omega is used to do unbreakable dashes and 22 | .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, 23 | .\" nothing in troff, for use with C<>. 24 | .tr \(*W- 25 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' 26 | .ie n \{\ 27 | . ds -- \(*W- 28 | . ds PI pi 29 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch 30 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch 31 | . ds L" "" 32 | . ds R" "" 33 | . ds C` "" 34 | . ds C' "" 35 | 'br\} 36 | .el\{\ 37 | . ds -- \|\(em\| 38 | . ds PI \(*p 39 | . ds L" `` 40 | . ds R" '' 41 | . ds C` 42 | . ds C' 43 | 'br\} 44 | .\" 45 | .\" Escape single quotes in literal strings from groff's Unicode transform. 46 | .ie \n(.g .ds Aq \(aq 47 | .el .ds Aq ' 48 | .\" 49 | .\" If the F register is turned on, we'll generate index entries on stderr for 50 | .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index 51 | .\" entries marked with X<> in POD. Of course, you'll have to process the 52 | .\" output yourself in some meaningful fashion. 53 | .\" 54 | .\" Avoid warning from groff about undefined register 'F'. 55 | .de IX 56 | .. 57 | .nr rF 0 58 | .if \n(.g .if rF .nr rF 1 59 | .if (\n(rF:(\n(.g==0)) \{ 60 | . if \nF \{ 61 | . de IX 62 | . tm Index:\\$1\t\\n%\t"\\$2" 63 | .. 64 | . if !\nF==2 \{ 65 | . nr % 0 66 | . nr F 2 67 | . \} 68 | . \} 69 | .\} 70 | .rr rF 71 | .\" 72 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). 73 | .\" Fear. Run. Save yourself. No user-serviceable parts. 74 | . \" fudge factors for nroff and troff 75 | .if n \{\ 76 | . ds #H 0 77 | . ds #V .8m 78 | . ds #F .3m 79 | . ds #[ \f1 80 | . ds #] \fP 81 | .\} 82 | .if t \{\ 83 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) 84 | . ds #V .6m 85 | . ds #F 0 86 | . ds #[ \& 87 | . ds #] \& 88 | .\} 89 | . \" simple accents for nroff and troff 90 | .if n \{\ 91 | . ds ' \& 92 | . ds ` \& 93 | . ds ^ \& 94 | . ds , \& 95 | . ds ~ ~ 96 | . ds / 97 | .\} 98 | .if t \{\ 99 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" 100 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' 101 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' 102 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' 103 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' 104 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' 105 | .\} 106 | . \" troff and (daisy-wheel) nroff accents 107 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' 108 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' 109 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] 110 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' 111 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' 112 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] 113 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] 114 | .ds ae a\h'-(\w'a'u*4/10)'e 115 | .ds Ae A\h'-(\w'A'u*4/10)'E 116 | . \" corrections for vroff 117 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' 118 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' 119 | . \" for low resolution devices (crt and lpr) 120 | .if \n(.H>23 .if \n(.V>19 \ 121 | \{\ 122 | . ds : e 123 | . ds 8 ss 124 | . ds o a 125 | . ds d- d\h'-1'\(ga 126 | . ds D- D\h'-1'\(hy 127 | . ds th \o'bp' 128 | . ds Th \o'LP' 129 | . ds ae ae 130 | . ds Ae AE 131 | .\} 132 | .rm #[ #] #H #V #F C 133 | .\" ======================================================================== 134 | .\" 135 | .IX Title "PLCAL 1" 136 | .TH PLCAL 1 "2017-10-28" "perl v5.22.1" "User Contributed Perl Documentation" 137 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes 138 | .\" way too many mistakes in technical documents. 139 | .if n .ad l 140 | .nh 141 | .SH "NAME" 142 | plcal \- Display a monthly calendar 143 | .SH "SYNOPSIS" 144 | .IX Header "SYNOPSIS" 145 | .Vb 2 146 | \& plcal [option] 147 | \& plcal \-\-help 148 | .Ve 149 | .SH "DESCRIPTION" 150 | .IX Header "DESCRIPTION" 151 | .Vb 1 152 | \& plcal is a simple command\-line calendar written in perl. 153 | .Ve 154 | .SH "OPTIONS" 155 | .IX Header "OPTIONS" 156 | .IP "\-b" 12 157 | .IX Item "-b" 158 | Use bracketed bolding (<>). 159 | .IP "\-h" 12 160 | .IX Item "-h" 161 | Disable highlighting. 162 | .IP "\-n" 12 163 | .IX Item "-n" 164 | Show next nomth. 165 | .IP "\-p" 12 166 | .IX Item "-p" 167 | Show previous month. 168 | .IP "\-\-help" 12 169 | .IX Item "--help" 170 | Display a help text and exit. 171 | .IP "\-\-date=\fBmm\fR \fByyyy\fR" 12 172 | .IX Item "--date=mm yyyy" 173 | Display a calendar for a specified month and year. 174 | .IP "\-\-month=\fBmm\fR" 12 175 | .IX Item "--month=mm" 176 | Show specified month in current year. 177 | .SH "NOTES" 178 | .IX Header "NOTES" 179 | The \-b option will be the default if the \s-1OS\s0 is Windows. 180 | .SH "AUTHOR" 181 | .IX Header "AUTHOR" 182 | Luciano D. Cecere 183 | .SH "LICENSE" 184 | .IX Header "LICENSE" 185 | \&\fBplcal\fR is free software; you can redistribute it and/or modify it 186 | under the terms of the \s-1GPL,\s0 or, optionally, Perl's license. 187 | -------------------------------------------------------------------------------- /man/showman.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | 3 | #set -- lcal.1 4 | 5 | case $1 in 6 | '') 7 | exit 1 8 | ;; 9 | *.gz) 10 | /usr/bin/man ./$1 11 | ;; 12 | *) 13 | /usr/bin/nroff -man $1 | less 14 | ;; 15 | esac 16 | -------------------------------------------------------------------------------- /perl/modules/Stardate/Changes: -------------------------------------------------------------------------------- 1 | Revision history for Perl extension Stardate. 2 | 3 | 0.01 Wed Jan 31 18:19:19 2018 4 | - original version; created by h2xs 1.23 with options 5 | -AXc -n Stardate 6 | 7 | -------------------------------------------------------------------------------- /perl/modules/Stardate/MANIFEST: -------------------------------------------------------------------------------- 1 | bin/monthly.sh 2 | bin/stardate.pl 3 | Changes 4 | lib/Stardate.pm 5 | Makefile.PL 6 | MANIFEST 7 | README 8 | t/Stardate.t 9 | -------------------------------------------------------------------------------- /perl/modules/Stardate/Makefile.PL: -------------------------------------------------------------------------------- 1 | use 5.022001; 2 | use ExtUtils::MakeMaker; 3 | 4 | WriteMakefile( 5 | NAME => 'Stardate', 6 | VERSION_FROM => 'lib/Stardate.pm', 7 | PREREQ_PM => {}, 8 | ABSTRACT_FROM => 'lib/Stardate.pm', 9 | AUTHOR => 'Luciano Dante Cecere ', 10 | LICENSE => 'perl', 11 | dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, 12 | EXE_FILES => [qw(bin/stardate.pl)], 13 | 14 | ); 15 | -------------------------------------------------------------------------------- /perl/modules/Stardate/README: -------------------------------------------------------------------------------- 1 | Stardate version 0.01 2 | ===================== 3 | 4 | MODULE 5 | 6 | Stardate 7 | 8 | 9 | USAGE 10 | 11 | use Stardate; 12 | 13 | my ($month, $day, $year) = @_; 14 | 15 | print_stardate($month, $day, $year) 16 | print_captains_log($month, $day, $year); 17 | 18 | 19 | INSTALLATION 20 | 21 | To install this module type the following: 22 | 23 | perl Makefile.PL 24 | make 25 | make test 26 | make install 27 | 28 | 29 | DEPENDENCIES 30 | 31 | This module requires these other modules and libraries: 32 | 33 | POSIX 34 | 35 | COPYRIGHT AND LICENCE 36 | 37 | 38 | Copyright (C) 2018 by dante 39 | 40 | This library is free software; you can redistribute it and/or modify 41 | it under the same terms as Perl itself, either Perl version 5.22.1 or, 42 | at your option, any later version of Perl 5 you may have available. 43 | -------------------------------------------------------------------------------- /perl/modules/Stardate/bin/monthly.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | # 3 | # SCRIPT: year.sh 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 02/01/2018-03:21:18 AM 6 | ######################################################################## 7 | # 8 | # year.sh - Stardate module example in a shell script 9 | # Copyright (C) 2018 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | m=${1:-$(date +%_m)} 27 | y=${2:-$(date +%Y)} 28 | 29 | if (( $y % 4 == 0 )) && (( $y % 100 != 0 )) || (( $y % 400 == 0 )); then 30 | len=("" 31 29 31 30 31 30 31 31 30 31 30 31) 31 | else 32 | len=("" 31 28 31 30 31 30 31 31 30 31 30 31) 33 | fi 34 | 35 | printf "%s | %s\n" "Earth Date" "Star Date" 36 | 37 | for ((d=1; d<=${len[m]}; d++)) 38 | do 39 | echo -n "$m $d $y | " 40 | perl -MStardate -e 'Stardate::print_stardate(@ARGV)' $m $d $y 41 | done 42 | 43 | echo 44 | -------------------------------------------------------------------------------- /perl/modules/Stardate/bin/stardate.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # SCRIPT: star.pl 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 02/01/2018-03:03:47 AM 6 | ######################################################################## 7 | # 8 | # star.pl - Example for Stardate.pm 9 | # Copyright (C) 2018 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | use strict; 27 | use warnings; 28 | use 5.010; 29 | 30 | use Stardate; 31 | 32 | if ( @ARGV and $ARGV[0] eq "-h" or @ARGV > 0 and @ARGV < 3 ) { 33 | print "Usage: stardate.pl [mm dd yyyy]\n"; 34 | exit(1); 35 | } 36 | elsif ( @ARGV == 3 ) { 37 | print_stardate(@ARGV); 38 | } 39 | else { 40 | use POSIX qw(strftime); 41 | my $month = strftime "%m", localtime; 42 | my $day = strftime "%d", localtime; 43 | my $year = strftime "%Y", localtime; 44 | 45 | # Only print Captain's Log for current date. 46 | print_captains_log( $month, $day, $year ); 47 | } 48 | -------------------------------------------------------------------------------- /perl/modules/Stardate/lib/Stardate.pm: -------------------------------------------------------------------------------- 1 | package Stardate; 2 | 3 | use 5.022001; 4 | use strict; 5 | use warnings; 6 | use POSIX qw(strftime); 7 | 8 | require Exporter; 9 | 10 | our @ISA = qw(Exporter); 11 | 12 | our @EXPORT = qw( 13 | print_stardate 14 | print_captains_log 15 | 16 | ); 17 | 18 | our $VERSION = '0.01'; 19 | 20 | our $month = strftime "%m", localtime; 21 | our $day = strftime "%d", localtime; 22 | our $year = strftime "%Y", localtime; 23 | 24 | our @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec ); 25 | our @month_length = (); 26 | our $year_len; 27 | 28 | our $b = 2323; 29 | our $c = 00000.00; 30 | 31 | sub month_array { 32 | our $y = $_[0]; 33 | if ( ( $y % 4 == 0 and $y % 100 != 0 ) or $y % 400 == 0 ) { 34 | @month_length = qw( 31 29 31 30 31 30 31 31 30 31 30 31 ); 35 | $year_len = 366; 36 | } 37 | else { 38 | @month_length = qw( 31 28 31 30 31 30 31 31 30 31 30 31 ); 39 | $year_len = 365; 40 | } 41 | } 42 | 43 | sub gregorian_to_stardate { 44 | our ( $month, $day, $year ) = @_; 45 | our %mon = (); 46 | 47 | month_array($year); 48 | 49 | our $len = 0; 50 | our $x = 1; 51 | $mon{0} = 0; 52 | foreach my $m (@month_length) { 53 | $mon{$x} = $len += $m; 54 | $x++; 55 | } 56 | 57 | our $stardate = 58 | $c + 59 | ( 1000 * ( $year - $b ) ) + 60 | ( ( 1000 / $year_len ) * ( $mon{ $month - 1 } + $day - 1 ) ); 61 | 62 | $stardate = sprintf( "%.2f", $stardate ); 63 | } 64 | 65 | sub print_stardate { 66 | our ( $month, $day, $year ) = @_; 67 | print gregorian_to_stardate( $month, $day, $year ) . "\n"; 68 | } 69 | 70 | sub print_captains_log { 71 | our ( $month, $day, $year ) = @_; 72 | print "Captain\'s log, stardate "; 73 | print gregorian_to_stardate( $month, $day, $year ) . "\n"; 74 | } 75 | 76 | 1; 77 | __END__ 78 | -------------------------------------------------------------------------------- /perl/modules/Stardate/t/Stardate.t: -------------------------------------------------------------------------------- 1 | # Before 'make install' is performed this script should be runnable with 2 | # 'make test'. After 'make install' it should work as 'perl Stardate.t' 3 | 4 | ######################### 5 | 6 | # change 'tests => 1' to 'tests => last_test_to_print'; 7 | 8 | use strict; 9 | use warnings; 10 | 11 | use Test::More tests => 1; 12 | BEGIN { use_ok('Stardate') }; 13 | 14 | ######################### 15 | 16 | # Insert your test code below, the Test::More module is use()ed here so read 17 | # its man page ( perldoc Test::More ) for help writing this test script. 18 | 19 | -------------------------------------------------------------------------------- /rcal/AUTHOR: -------------------------------------------------------------------------------- 1 | Luciano D. Cecere 2 | -------------------------------------------------------------------------------- /rcal/COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /rcal/README: -------------------------------------------------------------------------------- 1 | ==README for rcal 0.0.1 2 | rcal is a command-line calendar similar to cal (unix), gcal, ncal (bsd), 3 | and ddate (the Discordian calendar). Command-line arguments are easier 4 | in rcal (in my opinion) than the above programs. Any day can be bolded 5 | by passing MM DD YYYY as the arguments. 6 | 7 | Output of `rcal --help': 8 | 9 | PROGRAM: rcal - display a calendar 10 | AUTHOR: Luciano D. Cecere 11 | LICENSE: GPLv2 (2015) 12 | 13 | USAGE: 14 | rcal show current calendar 15 | rcal MM show month of current year 16 | rcal MM YYYY show month of year 17 | rcal MM DD YYYY show month and day of year 18 | rcal -d MM DD YYYY MM DD YYYY show days/years between two dates 19 | rcal -e YYYY show Western easter for YYYY 20 | rcal -h don't highlight the current day 21 | rcal -j MM DD YYYY show Julian (1..365) calendar 22 | rcal -n show next month 23 | rcal -p show previous month 24 | rcal -w MM YYY show week numbers 25 | rcal -y YYYY show yearly calendar 26 | rcal -D MM DD YYYY show day of week for date 27 | rcal -G MM DD YYYY show Julian day number (JDN) for date 28 | rcal -J JDN show Gregorian date for JDN 29 | rcal -V show version information and exit 30 | rcal -W show current week number 31 | rcal --ddate MM DD YYY show Discordian date for date 32 | rcal --help show this help and exit 33 | rcal --html MM DD YYYY generate HTML calendar 34 | rcal --ncal MM DD YYYY show calendar in ncal format 35 | rcal -3 MM YYYY show previous, current and next month 36 | 37 | NOTES: 38 | The -h flag must precede all other flags and args. 39 | With the -3 flag, the middle month and year can be set. 40 | The -y flag is optional if year is by itself. 41 | 42 | ==INSTALL 43 | run ./make.sh to: 44 | * build gem 45 | * install gem 46 | * install manpage 47 | -------------------------------------------------------------------------------- /rcal/bin/rcal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # encoding: utf-8 3 | # 4 | # SCRIPT: rcal.rb 5 | # AUTHOR: Luciano D. Cecere 6 | # DATE: 12/2015 7 | ######################################################################## 8 | # 9 | # rcal.rb - Display a calendar 10 | # Copyright (C) 2015 Luciano D. Cecere 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 2 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this program. If not, see . 24 | # 25 | ######################################################################## 26 | 27 | require 'calendar' 28 | require 'ncal' 29 | require 'discordia' 30 | require 'info' 31 | 32 | month = Calendar::MONTH 33 | day = Calendar::DAY 34 | year = Calendar::YEAR 35 | 36 | USAGE = "\ 37 | 38 | PROGRAM: rcal - display a calendar 39 | AUTHOR: Luciano D. Cecere 40 | LICENSE: GPLv2 (2015) 41 | 42 | USAGE: 43 | rcal show current calendar 44 | rcal MM show month of current year 45 | rcal MM YYYY show month of year 46 | rcal MM DD YYYY show month and day of year 47 | rcal -d MM DD YYYY MM DD YYYY show days/years between two dates 48 | rcal -e YYYY show Western easter for YYYY 49 | rcal -h don't highlight the current day 50 | rcal -j MM DD YYYY show Julian (1..365) calendar 51 | rcal -n show next month 52 | rcal -p show previous month 53 | rcal -w MM DD YYYY show week numbers 54 | rcal -y YYYY show yearly calendar 55 | rcal -D MM DD YYYY show day of week for date 56 | rcal -G MM DD YYYY show Julian day number (JDN) for date 57 | rcal -J JDN show Gregorian date for JDN 58 | rcal -V show version information and exit 59 | rcal -W show current week number 60 | rcal --ddate MM DD YYYY show Discordian date for date 61 | rcal --help show this help and exit 62 | rcal --html MM DD YYYY generate HTML calendar 63 | rcal --ncal MM DD YYYY show calendar in ncal format 64 | rcal -3 MM YYYY show previous, current and next month 65 | 66 | NOTES: 67 | The -h flag must precede all other flags and args. 68 | With the -3 flag, the middle month and year can be set. 69 | The -y flag is optional if year is by itself. 70 | 71 | " 72 | 73 | ### PARSE COMMAND LINE OPTIONS ### 74 | 75 | if(ARGV[0] == "--help") then 76 | puts(USAGE) 77 | exit 78 | end 79 | 80 | if(ARGV[0] == "-V") then 81 | puts "rcal #{Rcal_info::VERSION}" 82 | puts "#{Rcal_info::INFO}" 83 | exit 84 | end 85 | 86 | cal = Calendar.new(month, day, year) 87 | 88 | julian = nil 89 | show_week = nil 90 | html = nil 91 | three = nil 92 | ncal = nil 93 | no_highlight = nil 94 | 95 | if(ARGV[0] == "-3") then 96 | ARGV.shift 97 | three = 1 98 | end 99 | 100 | if(ARGV[0] == "-y") then 101 | ARGV.shift 102 | if(ARGV.length == 1) then 103 | cal.d = nil 104 | cal.y = ARGV[0] 105 | cal.yearly 106 | else 107 | cal.d = nil 108 | cal.yearly 109 | end 110 | exit 111 | end 112 | 113 | if(ARGV[0] == "--ddate") then 114 | d = Discordia.new(month, day, year) 115 | ARGV.shift 116 | if(ARGV.length == 3) then 117 | d.m, d.d, d.y = ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i 118 | end 119 | d.print_discordian_date 120 | exit 121 | end 122 | 123 | if(ARGV[0] == "-d") then 124 | ARGV.shift 125 | if(ARGV.length == 6) then 126 | cal.diff_date_2(ARGV[0], ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5]) 127 | exit 128 | elsif(ARGV.length == 3) then 129 | cal.diff_date_1(ARGV[0], ARGV[1], ARGV[2]) 130 | exit 131 | else 132 | puts("The -d flag format is: MM DD YYYY MM DD YYYY") 133 | puts Calendar::HELP 134 | exit 1 135 | end 136 | end 137 | 138 | if(ARGV[0] == "-D") then 139 | ARGV.shift 140 | if(ARGV.length == 3) then 141 | cal.m, cal.d, cal.y = ARGV[0], ARGV[1], ARGV[2] 142 | puts Calendar::WEEKDAYS[cal.day_of_week(cal.m, cal.d, cal.y)] 143 | exit 144 | elsif(ARGV.length == 0) then 145 | puts Calendar::WEEKDAYS[cal.day_of_week(month, day, year)] 146 | exit 147 | else 148 | puts("Not enought args") 149 | puts Calendar::HELP 150 | exit 1 151 | end 152 | end 153 | 154 | if(ARGV[0] == "-e") then 155 | ARGV.shift 156 | if(ARGV.length == 1) then 157 | month, day, year = cal.western_easter(ARGV[0]) 158 | m = Calendar::MONTH_NAMES[month] 159 | puts("#{m} #{day} #{year}") 160 | else 161 | month, day, year = cal.get_western_easter 162 | m = Calendar::MONTH_NAMES[month] 163 | puts("#{m} #{day} #{year}") 164 | end 165 | exit 166 | end 167 | 168 | if(ARGV[0] == "-G") then 169 | ARGV.shift 170 | if(ARGV.length == 3) then 171 | month, day, year = ARGV[0], ARGV[1], ARGV[2] 172 | end 173 | puts(cal.gregorian_date_to_julian_date(month, day, year)) 174 | exit 175 | end 176 | 177 | if(ARGV[0] == "-J") then 178 | ARGV.shift 179 | if(ARGV.length != 1) then 180 | puts("Mising Julian day number") 181 | puts Calendar::HELP 182 | exit 1 183 | end 184 | month, day, year = cal.julian_day_to_gregorian_day(ARGV[0]) 185 | puts("#{month} #{day} #{year}") 186 | exit 187 | end 188 | 189 | if(ARGV[0] == "-h") then 190 | ARGV.shift 191 | no_highlight = 1 192 | cal.d = nil 193 | end 194 | 195 | if(ARGV[0] == "--html") then 196 | ARGV.shift 197 | html = 1 198 | end 199 | 200 | if(ARGV[0] == "-j") then 201 | ARGV.shift 202 | julian = 1 203 | if(ARGV.length == 1) then 204 | if(ARGV[0] == "-y") then 205 | cal.d = nil 206 | cal.j_yearly 207 | exit 208 | else 209 | cal.m = ARGV[0] 210 | cal.d = nil 211 | end 212 | elsif(ARGV.length == 2) then 213 | if(ARGV[0] == "-y") then 214 | cal.y = ARGV[1] 215 | cal.d = nil 216 | cal.j_yearly 217 | exit 218 | else 219 | cal.m, cal.y = ARGV[0], ARGV[1] 220 | cal.d = nil 221 | end 222 | elsif(ARGV.length == 3) then 223 | cal.m, cal.d, cal.y = ARGV[0], ARGV[1], ARGV[2] 224 | end 225 | cal.d = nil if(no_highlight) 226 | end 227 | 228 | if(ARGV[0] == "--ncal") then 229 | ncal = 1 230 | nc = Ncal.new(month, day, year) 231 | ARGV.shift 232 | if(ARGV.length == 1) then 233 | if(ARGV[0] == "-y") then 234 | nc.d = nil 235 | nc.ncal_yearly 236 | exit 237 | elsif(ARGV[0] == "-j") then 238 | nc.d = nil if(no_highlight) 239 | nc.j_print_ncal 240 | exit 241 | else 242 | nc.m = ARGV[0] 243 | nc.d = nil 244 | end 245 | elsif(ARGV.length == 2) then 246 | if(ARGV[0] == "-j") && (ARGV[1] == "-y") then 247 | nc.d = nil 248 | nc.j_ncal_yearly 249 | exit 250 | elsif(ARGV[0] == "-j") then 251 | nc.m = ARGV[1] 252 | nc.d = nil 253 | nc.j_print_ncal 254 | exit 255 | elsif(ARGV[0] == "-y") then 256 | nc.y = ARGV[1] 257 | nc.d = nil 258 | nc.ncal_yearly 259 | exit 260 | else 261 | nc.m = ARGV[0] 262 | nc.y = ARGV[1] 263 | nc.d = nil 264 | end 265 | elsif(ARGV.length == 3) then 266 | if(ARGV[0] == "-j") && (ARGV[1] == "-y") then 267 | nc.y = ARGV[2] 268 | nc.d = nil 269 | nc.j_ncal_yearly 270 | exit 271 | end 272 | if(ARGV[0] == "-j") then 273 | nc.m = ARGV[1] 274 | nc.y = ARGV[2] 275 | nc.d = nil 276 | nc.j_print_ncal 277 | exit 278 | else 279 | nc.m, nc.d, nc.y = ARGV[0], ARGV[1], ARGV[2] 280 | nc.d = nil if(no_highlight) 281 | end 282 | elsif(ARGV.length == 4) then 283 | if(ARGV[0] == "-j") 284 | nc.m, nc.d, nc.y = ARGV[1], ARGV[2], ARGV[3] 285 | nc.d = nil if(no_highlight) 286 | nc.j_print_ncal 287 | exit 288 | end 289 | elsif(ARGV.length == 2) then 290 | nc.m, nc.d, nc.y = ARGV[0], nil, ARGV[1] 291 | end 292 | end 293 | 294 | if(ARGV[0] == "-w") then 295 | ARGV.shift 296 | show_week = 1 297 | end 298 | 299 | if(ARGV[0] == "-W") then 300 | puts cal.week_num(month.to_i, day.to_i, year.to_i) 301 | exit 302 | end 303 | 304 | if(ARGV[0] == "-p") then 305 | cal.shift_month_backward 306 | cal.print_g_monthly 307 | exit 308 | end 309 | 310 | if(ARGV[0] == "-n") then 311 | cal.shift_month_forward 312 | cal.print_g_monthly 313 | exit 314 | end 315 | 316 | if(ARGV.length == 1) then 317 | if(ARGV[0].to_i >= 1753) && (ARGV[0].to_i <= 9999) then 318 | cal.d = nil 319 | cal.y = ARGV[0] 320 | cal.yearly 321 | exit 322 | else 323 | cal.m, cal.d = ARGV[0].to_i, nil 324 | end 325 | end 326 | 327 | if(ARGV.length == 2) then 328 | cal.m, cal.d, cal.y = ARGV[0].to_i, nil, ARGV[1].to_i 329 | end 330 | 331 | if(ARGV.length == 3) then 332 | cal.m, cal.d, cal.y = ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i 333 | end 334 | 335 | cal.d = nil if(no_highlight) 336 | 337 | ### PROGRAM START ### 338 | 339 | if(julian) 340 | cal.print_j_monthly 341 | elsif(show_week) 342 | cal.print_weeknums 343 | elsif(html) 344 | cal.to_html 345 | elsif(three) 346 | cal.month3 347 | elsif(ncal) 348 | nc.d = nil if(no_highlight) 349 | nc.print_ncal 350 | else 351 | cal.print_g_monthly 352 | end 353 | 354 | ### EOF #################################################################### 355 | -------------------------------------------------------------------------------- /rcal/lib/discordia.rb: -------------------------------------------------------------------------------- 1 | class Discordia < Calendar 2 | 3 | WEEKDAY = [ 4 | "Sweetmorn", 5 | "Boomtime", 6 | "Pungenday", 7 | "Prickle-Prickle", 8 | "Setting Orange" 9 | ].freeze 10 | 11 | APOSTLE = [ 12 | "Mungday", 13 | "Mojoday", 14 | "Syaday", 15 | "Zaraday", 16 | "Maladay" 17 | ].freeze 18 | 19 | HOLYDAY = [ 20 | "Chaoflux", 21 | "Discoflux", 22 | "Confuflux", 23 | "Bureflux", 24 | "Afflux" 25 | ].freeze 26 | 27 | SEASONS = [ 28 | "Chaos", 29 | "Discord", 30 | "Confusion", 31 | "Bureaucracy", 32 | "The Aftermath" 33 | ].freeze 34 | 35 | def initialize(m, d, y) 36 | super(m, d, y) 37 | end 38 | 39 | def print_discordian_date 40 | initialize(@m, @d, @y) 41 | year = @y + 1166 42 | 43 | if(get_month_len == 29) && (@m == 2) && (@d == 29) then 44 | puts("St. Tib's Day, #{year} YOLD") 45 | exit 46 | end 47 | 48 | dayofyear = get_diy 49 | 50 | if(is_leap(@y) == 29) && (dayofyear >= 60) then 51 | dayofyear -= 1 52 | end 53 | 54 | seasonday = dayofyear % 73 55 | seasonday = 73 if(seasonday == 0) 56 | 57 | case seasonday 58 | when 5 then 59 | puts("Today is #{APOSTLE[dayofyear / 73]}, in the YOLD #{year}") 60 | exit 61 | when 50 then 62 | puts("Today is #{HOLYDAY[dayofyear / 73]}, in the YOLD #{year}") 63 | exit 64 | else 65 | case dayofyear 66 | when 73, 146, 219, 291, 365 then 67 | season = SEASONS[(dayofyear / 73) - 1] 68 | else 69 | season = SEASONS[(dayofyear / 73)] 70 | end 71 | end 72 | 73 | dayofweek = WEEKDAY[(dayofyear - 1) % 5] 74 | 75 | ord = ordinal(seasonday) 76 | puts("Today is #{dayofweek}, the #{ord} day of #{season} in the YOLD #{year}") 77 | end 78 | 79 | end 80 | -------------------------------------------------------------------------------- /rcal/lib/hebrew.rb: -------------------------------------------------------------------------------- 1 | 2 | # This module is not finished. 3 | 4 | module Hebrew 5 | 6 | def self.j_to_sdn(m, d, y) 7 | m, d, y = m.to_i, d.to_i, y.to_i 8 | 9 | if y == 0 || y < -4713 || m <=0 || m > 12 || m <= 0 || d > 31 10 | return(0) 11 | end 12 | 13 | if y == -4713 && m == 1 && m == 1 14 | return(0) 15 | end 16 | 17 | (y < 0) ? year = y + 4801 : year = y + 4800 18 | 19 | if m > 2 20 | month = m - 3 21 | else 22 | month = m + 9 23 | year -= 1 24 | end 25 | 26 | ((year * 1461) / 4) + ((month * 153 + 2) / 5) + (d - 32083) 27 | end 28 | 29 | def self.sdn_to_j(sdn, m, d, y) 30 | sdn, m, d, y = sdn.to_i, m.to_i, d.to_i, y.to_i 31 | 32 | if sdn <= 347997 33 | m, d, y = 0, 0, 0 34 | return 35 | end 36 | 37 | day = sdn - 347997 38 | 39 | # unfinished 40 | end 41 | 42 | def self.molad(mcycle) 43 | mcycle = mcycle.to_i 44 | 45 | r1 = 31524 46 | r1 += mcycle * (765433 & 65535) 47 | r2 = ri >> 16 48 | r2 += mcycle * (765433 >> 16) & 65535 49 | d2 = r2 / 25920 50 | r2 -= d2 * 25920 51 | r1 = (r2 << 16) | ( r1 & 65535) 52 | d1 = r1 / 25920 53 | r1 -= d1 * 25920 54 | 55 | moladday = (d1 << 16) | d1 56 | mhalakim = r1 57 | 58 | [ moladday, mhalakim ] 59 | end 60 | 61 | def self.tishri1(myear, mday, mhalakim) 62 | myear, mday, mhalakim = myear.to_i, mday.to_i, mhalakim.to_i 63 | 64 | tishri1 = mday 65 | dow = tishri1 % 7 66 | case myear 67 | when 2,5,7,10,13,16,18 then leap = myear 68 | end 69 | case myear 70 | when 3,6,8,11,14,17,0 then lastleap = myear 71 | end 72 | 73 | if mhalakim >= 101376 || ((!leap) && dow == 2 && mhalakim >= 229914) || 74 | (lastleap && dow == 1 && mhalakim >= 560269) 75 | tishri1 += 1 76 | dow += 1 77 | dow = 0 if dow == 7 78 | end 79 | 80 | case dow 81 | when 3,5,0 then tishri1 += 1 82 | end 83 | 84 | tishri1 85 | end 86 | 87 | end 88 | -------------------------------------------------------------------------------- /rcal/lib/info.rb: -------------------------------------------------------------------------------- 1 | module Rcal_info #:nodoc: 2 | 3 | PROJECT_NAME = "rcal" 4 | VERSION = "0.0.1" 5 | AUTHOR = "Luciano D. Cecere" 6 | EMAIL = "ldante86@aol.com" 7 | SUMMARY = "A command-line calendar" 8 | LICENSE = "GPL-2" 9 | YEAR = 2015 10 | 11 | INFO = "\ 12 | Copyleft (c) #{YEAR} #{AUTHOR} 13 | This is free software; see the source for copying conditions. 14 | There is NO warranty, without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\ 16 | " 17 | 18 | DESCRIPTION = "\ 19 | rcal is a command-line calendar similar to ncal(BSD) 20 | and other cal-like programs. Formats include Gregorian 21 | Julian, Discordian and HTML.' 22 | " 23 | end 24 | -------------------------------------------------------------------------------- /rcal/lib/ncal.rb: -------------------------------------------------------------------------------- 1 | class Ncal < Calendar 2 | 3 | WEEKS = [ "Su ", "Mo ", "Tu ", "We ", "Th ", "Fr ", "Sa " ].freeze 4 | 5 | def initialize(m, d, y) 6 | super(m, d, y) 7 | end 8 | 9 | def load_ncal_array 10 | load_g_array 11 | c = get_array 12 | 13 | @rows = [ 14 | c[0], c[7], c[14], c[21], c[28], c[35], 15 | c[1], c[8], c[15], c[22], c[29], c[36], 16 | c[2], c[9], c[16], c[23], c[30], c[37], 17 | c[3], c[10], c[17], c[24], c[31], c[38], 18 | c[4], c[11], c[18], c[25], c[32], c[39], 19 | c[5], c[12], c[19], c[26], c[33], c[40], 20 | c[6], c[13], c[20], c[27], c[34], c[41], 21 | ].freeze 22 | end 23 | 24 | def load_j_ncal_array 25 | load_j_array 26 | c = get_array 27 | 28 | @rows = [ 29 | c[0], c[7], c[14], c[21], c[28], c[35], 30 | c[1], c[8], c[15], c[22], c[29], c[36], 31 | c[2], c[9], c[16], c[23], c[30], c[37], 32 | c[3], c[10], c[17], c[24], c[31], c[38], 33 | c[4], c[11], c[18], c[25], c[32], c[39], 34 | c[5], c[12], c[19], c[26], c[33], c[40], 35 | c[6], c[13], c[20], c[27], c[34], c[41], 36 | ].freeze 37 | end 38 | 39 | def print_ncal 40 | initialize(@m, @d, @y) 41 | 42 | load_ncal_array 43 | 44 | puts " #{MONTH_NAMES[@m]} #{@y}" 45 | 46 | t = -1 47 | @rows.length.times do |i| 48 | if(i == 0) 49 | print WEEKS[t+=1] 50 | elsif(i % 6 == 0) 51 | puts 52 | print WEEKS[t+=1] 53 | end 54 | if(@rows[i].to_i == @d.to_i) && (@rows[i].to_i < 10) && (@d > 0) then 55 | printf("\e[7m %d\e[27m ", @d) 56 | elsif(@rows[i].to_i == @d.to_i) && (@rows[i].to_i > 9) && (@d > 0) then 57 | printf("\e[7m%d\e[27m ", @d) 58 | else 59 | print(@rows[i]) 60 | end 61 | end 62 | puts 63 | end 64 | 65 | def j_print_ncal 66 | initialize(@m, @d, @y) 67 | 68 | load_j_ncal_array 69 | 70 | puts " #{MONTH_NAMES[@m]} #{@y}" 71 | 72 | jd = get_diy 73 | 74 | t = -1 75 | @rows.length.times do |i| 76 | if(i == 0) 77 | print WEEKS[t+=1] 78 | elsif(i % 6 == 0) 79 | puts 80 | print WEEKS[t+=1] 81 | end 82 | if(@rows[i].to_i == jd) && (@rows[i].to_i < 10) && (jd > 0) then 83 | printf("\e[7m %d\e[27m ", jd) 84 | elsif(@rows[i].to_i == jd) && (@rows[i].to_i > 9) && (@rows[i].to_i < 100) && (jd > 0) then 85 | printf("\e[7m %d\e[27m ", jd) 86 | elsif(@rows[i].to_i == jd) && (@rows[i].to_i > 99) && (jd > 0) then 87 | printf("\e[7m%d\e[27m ", jd) 88 | else 89 | print(@rows[i]) 90 | end 91 | end 92 | puts 93 | end 94 | 95 | def ncal_yearly 96 | initialize(@m, @d, @y) 97 | 98 | y = get_year.to_s 99 | printf("\n%*d\n\n", ((74 + y.size) / 2), "#{y}") 100 | 101 | @m = 0 102 | (1..3).each do | | 103 | @m += 1 104 | load_ncal_array 105 | c1_row1 = @rows[0,6].join 106 | c1_row2 = @rows[6,6].join 107 | c1_row3 = @rows[12,6].join 108 | c1_row4 = @rows[18,6].join 109 | c1_row5 = @rows[24,6].join 110 | c1_row6 = @rows[30,6].join 111 | c1_row7 = @rows[36,6].join 112 | m = get_month_name 113 | y = get_year 114 | printf("%s", " #{m}") 115 | printf("%*s", 18 - m.length, "") 116 | 117 | @m += 1 118 | load_ncal_array 119 | c2_row1 = @rows[0,6].join 120 | c2_row2 = @rows[6,6].join 121 | c2_row3 = @rows[12,6].join 122 | c2_row4 = @rows[18,6].join 123 | c2_row5 = @rows[24,6].join 124 | c2_row6 = @rows[30,6].join 125 | c2_row7 = @rows[36,6].join 126 | m = get_month_name 127 | y = get_year 128 | printf("%s", " #{m}") 129 | printf("%*s", 18 - m.length, "") 130 | 131 | @m += 1 132 | load_ncal_array 133 | c3_row1 = @rows[0,6].join 134 | c3_row2 = @rows[6,6].join 135 | c3_row3 = @rows[12,6].join 136 | c3_row4 = @rows[18,6].join 137 | c3_row5 = @rows[24,6].join 138 | c3_row6 = @rows[30,6].join 139 | c3_row7 = @rows[36,6].join 140 | m = get_month_name 141 | y = get_year 142 | printf("%s", " #{m}") 143 | printf("%*s", 18 - m.length, "") 144 | 145 | @m += 1 146 | load_ncal_array 147 | c4_row1 = @rows[0,6].join 148 | c4_row2 = @rows[6,6].join 149 | c4_row3 = @rows[12,6].join 150 | c4_row4 = @rows[18,6].join 151 | c4_row5 = @rows[24,6].join 152 | c4_row6 = @rows[30,6].join 153 | c4_row7 = @rows[36,6].join 154 | m = get_month_name 155 | y = get_year 156 | printf("%s\n", " #{m}") 157 | 158 | print WEEKS[0], c1_row1, " ", c2_row1, " ", c3_row1, " ", c4_row1 ; puts 159 | print WEEKS[1], c1_row2, " ", c2_row2, " ", c3_row2, " ", c4_row2 ; puts 160 | print WEEKS[2], c1_row3, " ", c2_row3, " ", c3_row3, " ", c4_row3 ; puts 161 | print WEEKS[3], c1_row4, " ", c2_row4, " ", c3_row4, " ", c4_row4 ; puts 162 | print WEEKS[4], c1_row5, " ", c2_row5, " ", c3_row5, " ", c4_row5 ; puts 163 | print WEEKS[5], c1_row6, " ", c2_row6, " ", c3_row6, " ", c4_row6 ; puts 164 | print WEEKS[6], c1_row7, " ", c2_row7, " ", c3_row7, " ", c4_row7 ; puts 165 | puts 166 | end 167 | end 168 | 169 | def j_ncal_yearly 170 | initialize(@m, @d, @y) 171 | 172 | y = get_year.to_s 173 | printf("\n%*d\n\n", ((72 + y.size) / 2), "#{y}") 174 | 175 | @m = 0 176 | (1..4).each do | | 177 | @m += 1 178 | load_j_ncal_array 179 | c1_row1 = @rows[0,6].join 180 | c1_row2 = @rows[6,6].join 181 | c1_row3 = @rows[12,6].join 182 | c1_row4 = @rows[18,6].join 183 | c1_row5 = @rows[24,6].join 184 | c1_row6 = @rows[30,6].join 185 | c1_row7 = @rows[36,6].join 186 | m = get_month_name 187 | y = get_year 188 | printf("%s", " #{m}") 189 | printf("%*s", 21 - m.length, "") 190 | 191 | @m += 1 192 | load_j_ncal_array 193 | c2_row1 = @rows[0,6].join 194 | c2_row2 = @rows[6,6].join 195 | c2_row3 = @rows[12,6].join 196 | c2_row4 = @rows[18,6].join 197 | c2_row5 = @rows[24,6].join 198 | c2_row6 = @rows[30,6].join 199 | c2_row7 = @rows[36,6].join 200 | m = get_month_name 201 | y = get_year 202 | printf("%s", " #{m}") 203 | printf("%*s", 21 - m.length, "") 204 | 205 | @m += 1 206 | load_j_ncal_array 207 | c3_row1 = @rows[0,6].join 208 | c3_row2 = @rows[6,6].join 209 | c3_row3 = @rows[12,6].join 210 | c3_row4 = @rows[18,6].join 211 | c3_row5 = @rows[24,6].join 212 | c3_row6 = @rows[30,6].join 213 | c3_row7 = @rows[36,6].join 214 | m = get_month_name 215 | y = get_year 216 | printf("%s\n", " #{m}") 217 | 218 | print WEEKS[0], c1_row1, " ", c2_row1, " ", c3_row1 ; puts 219 | print WEEKS[1], c1_row2, " ", c2_row2, " ", c3_row2 ; puts 220 | print WEEKS[2], c1_row3, " ", c2_row3, " ", c3_row3 ; puts 221 | print WEEKS[3], c1_row4, " ", c2_row4, " ", c3_row4 ; puts 222 | print WEEKS[4], c1_row5, " ", c2_row5, " ", c3_row5 ; puts 223 | print WEEKS[5], c1_row6, " ", c2_row6, " ", c3_row6 ; puts 224 | print WEEKS[6], c1_row7, " ", c2_row7, " ", c3_row7 ; puts 225 | puts 226 | end 227 | end 228 | 229 | end 230 | -------------------------------------------------------------------------------- /rcal/make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | 3 | VERSION=0.0.1 4 | GEM=rcal-${VERSION}.gem 5 | 6 | iman() 7 | { 8 | local manfile="${1}" 9 | local section=${2:-1} 10 | if [ -z ${manfile} ]; then 11 | echo Usage: ${FUNCNAME} file.1[.gz] section-number 12 | return 1 13 | else 14 | if [ ! -e ${manfile} ]; then 15 | echo ${manfile} not found 16 | return 1 17 | else 18 | case ${1} in 19 | *.[1-9]) 20 | /bin/gzip ${1}; 21 | sudo cp ${manfile}.gz /usr/share/man/man${section} 22 | /bin/gunzip ${manfile}.gz 23 | ;; 24 | *.[1-9].gz) 25 | sudo cp ${manfile} /usr/share/man/man${section} 26 | ;; 27 | *) 28 | echo ${manfile} is not a manual file 29 | return 1 30 | ;; 31 | esac 32 | fi 33 | fi 34 | } 35 | 36 | sudo id >/dev/null 37 | 38 | gem build rcal.gemspec 39 | 40 | sudo gem install $GEM 41 | 42 | rm $GEM 43 | 44 | iman "man/rcal.1" && { 45 | echo manual installed 46 | } || { 47 | echo manual not installed 48 | } 49 | 50 | rdoc --quiet 51 | -------------------------------------------------------------------------------- /rcal/man/rcal.1: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn/v0.7.3 2 | .\" http://github.com/rtomayko/ronn/tree/0.7.3 3 | . 4 | .TH "RCAL" "1" "September 2016" "" "" 5 | . 6 | .SH "NAME" 7 | \fBrcal\fR \- display a calendar 8 | . 9 | .SH "SYNOPSIS" 10 | \fBrcal\fR [\fIoptions\fR] [[[day] month] year] 11 | . 12 | .SH "DESCRIPTION" 13 | \fBrcal\fR is a command\-line calendar similar to cal/ncal\. 14 | . 15 | .SH "OPTIONS" 16 | . 17 | .IP "\(bu" 4 18 | \fB\-d\fR Show days/years between two dates\. 19 | . 20 | .IP "\(bu" 4 21 | \fB\-e\fR Show Western easter\. 22 | . 23 | .IP "\(bu" 4 24 | \fB\-h\fR Turn off highlighting\. 25 | . 26 | .IP "\(bu" 4 27 | \fB\-j\fR Show the Julian calendar\. 28 | . 29 | .IP "\(bu" 4 30 | \fB\-n\fR Show next month\. 31 | . 32 | .IP "\(bu" 4 33 | \fB\-p\fR Show the previous month\. 34 | . 35 | .IP "\(bu" 4 36 | \fB\-w\fR Show weeknumbers next to default calendar\. 37 | . 38 | .IP "\(bu" 4 39 | \fB\-y\fR Show yearly calendar\. 40 | . 41 | .IP "\(bu" 4 42 | \fB\-D\fR Show day of week\. 43 | . 44 | .IP "\(bu" 4 45 | \fB\-G\fR Show Julian day number (JDN)\. 46 | . 47 | .IP "\(bu" 4 48 | \fB\-J\fR Show Gregorian date for JDN\. 49 | . 50 | .IP "\(bu" 4 51 | \fB\-V\fR Show version information and exit\. 52 | . 53 | .IP "\(bu" 4 54 | \fB\-W\fR Show current week number\. 55 | . 56 | .IP "\(bu" 4 57 | \fB\-\-ddate\fR Show Discordian date\. 58 | . 59 | .IP "\(bu" 4 60 | \fB\-\-help\fR Show usage information and exit\. 61 | . 62 | .IP "\(bu" 4 63 | \fB\-\-html\fR Generate a calendar in raw HTML\. 64 | . 65 | .IP "\(bu" 4 66 | \fB\-\-ncal\fR Show calendar in ncal format\. 67 | . 68 | .IP "\(bu" 4 69 | \fB\-3\fR Show previous, current and next month\. 70 | . 71 | .IP "" 0 72 | . 73 | .SH "PARAMETERS" 74 | A single parameter specifies the month (1\-12) to be displayed\. 75 | . 76 | .P 77 | Two parameters specify month and year\. 78 | . 79 | .P 80 | Three parameters specify the month, day and year; the day will be highlighted\. 81 | . 82 | .SH "NOTES" 83 | The \fB\-h\fR flag must precede all other flags and args\. 84 | . 85 | .P 86 | With the \fB\-3\fR flag, the middle month and year can be set\. 87 | . 88 | .P 89 | The \fB\-y\fR flag is optional if a year is the only argument\. 90 | . 91 | .P 92 | The \fB\-y\fR flag may come after \fB\-j\fR and \fB\-\-ncal\fR followed by a year\. 93 | . 94 | .P 95 | The \fB\-y\fR and \fB\-3\fR flags don\'t support highlighting\. 96 | . 97 | .SH "EXAMPLES" 98 | rcal \-\-ncal \-j \-y 2000 99 | . 100 | .P 101 | rcal 10 28 1986 102 | . 103 | .P 104 | rcal \-J 2446732 105 | . 106 | .P 107 | rcal \-h \-j 10 108 | . 109 | .P 110 | rcal \-\-html > today\.html 111 | . 112 | .P 113 | rcal 2015 114 | . 115 | .SH "HISTORY" 116 | This program started its life as a 5000+ line bash script called lcal I wrote several years ago\. It was my favorite shell program \- it has over 50 command\-line flags! \- but because it was so slow, I chose to make an implementation using the Ruby language\. 117 | . 118 | .SH "AUTHOR" 119 | rcal and this manual were written by Luciano D\. Cecere 120 | . 121 | .SH "LICENSE" 122 | GPLv2 \- 2015 123 | . 124 | .SH "SEE ALSO" 125 | cal(1), ddate(1), ncal(1) 126 | -------------------------------------------------------------------------------- /rcal/man/rcal.1.ronn: -------------------------------------------------------------------------------- 1 | rcal(1) -- display a calendar 2 | ============================= 3 | 4 | ## SYNOPSIS 5 | 6 | `rcal` [] [[[day] month] year] 7 | 8 | ## DESCRIPTION 9 | 10 | **rcal** is a command-line calendar similar to cal/ncal. 11 | 12 | ## OPTIONS 13 | 14 | * `-d` 15 | Show days/years between two dates. 16 | * `-e` 17 | Show Western easter. 18 | * `-h` 19 | Turn off highlighting. 20 | * `-j` 21 | Show the Julian calendar. 22 | * `-n` 23 | Show next month. 24 | * `-p` 25 | Show the previous month. 26 | * `-w` 27 | Show weeknumbers next to default calendar. 28 | * `-y` 29 | Show yearly calendar. 30 | * `-D` 31 | Show day of week. 32 | * `-G` 33 | Show Julian day number (JDN). 34 | * `-J` 35 | Show Gregorian date for JDN. 36 | * `-V` 37 | Show version information and exit. 38 | * `-W` 39 | Show current week number. 40 | * `--ddate` 41 | Show Discordian date. 42 | * `--help` 43 | Show usage information and exit. 44 | * `--html` 45 | Generate a calendar in raw HTML. 46 | * `--ncal` 47 | Show calendar in ncal format. 48 | * `-3` 49 | Show previous, current and next month. 50 | 51 | ##PARAMETERS 52 | A single parameter specifies the month (1-12) to be displayed. 53 | 54 | Two parameters specify month and year. 55 | 56 | Three parameters specify the month, day and year; the day will be highlighted. 57 | 58 | ##NOTES 59 | The `-h` flag must precede all other flags and args. 60 | 61 | With the `-3` flag, the middle month and year can be set. 62 | 63 | The `-y` flag is optional if a year is the only argument. 64 | 65 | The `-y` flag may come after `-j` and `--ncal` followed by a year. 66 | 67 | The `-y` and `-3` flags don't support highlighting. 68 | 69 | ##EXAMPLES 70 | 71 | rcal --ncal -j -y 2000 72 | 73 | rcal 10 28 1986 74 | 75 | rcal -J 2446732 76 | 77 | rcal -h -j 10 78 | 79 | rcal --html > today.html 80 | 81 | rcal 2015 82 | 83 | ##HISTORY 84 | This program started its life as a 5000+ line bash script called lcal 85 | I wrote several years ago. It was my favorite shell program - it has 86 | over 50 command-line flags! - but because it was so slow, I chose to make an 87 | implementation using the Ruby language. 88 | 89 | ##AUTHOR 90 | rcal and this manual were written by Luciano D. Cecere 91 | 92 | ##LICENSE 93 | GPLv2 - 2015 94 | 95 | ##SEE ALSO 96 | cal(1), ddate(1), ncal(1) 97 | -------------------------------------------------------------------------------- /rcal/rcal.gemspec: -------------------------------------------------------------------------------- 1 | lib = File.expand_path('../lib/', __FILE__) 2 | $:.unshift lib unless $:.include?(lib) 3 | 4 | require 'info' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = Rcal_info::PROJECT_NAME 8 | gem.version = Rcal_info::VERSION 9 | gem.date = Rcal_info::YEAR 10 | gem.summary = Rcal_info::SUMMARY 11 | gem.description = Rcal_info::DESCRIPTION 12 | gem.authors = Rcal_info::AUTHOR 13 | gem.email = Rcal_info::EMAIL 14 | gem.license = Rcal_info::LICENSE 15 | 16 | gem.rubyforge_project = Rcal_info::PROJECT_NAME 17 | 18 | gem.files = Dir.glob("{bin,lib,man,tests,scripts}/**/*") + 19 | [ "README", "AUTHOR", 'make.sh' ] 20 | 21 | gem.executables = 'rcal' 22 | gem.require_path = 'lib' 23 | end 24 | -------------------------------------------------------------------------------- /rcal/scripts/ddate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SCRIPT: ddate.sh 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 06/15/2015-01:13:37 PM 6 | ######################################################################## 7 | # 8 | # ddate.sh - Generate Discordian date (ddate clone) 9 | # Copyright (C) 2015 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | export PATH=/bin:/usr/bin 27 | unalias -a 28 | PROGRAM="${0##*/}" 29 | 30 | WEEKDAY=(Sweetmorn Boomtime Pungenday Prickle-Prickle "Setting Orange") 31 | APOSTLE=(Mungday Mojoday Syaday Zaraday Maladay) 32 | HOLYDAY=(Chaoflux Discoflux Confuflux Bureflux Afflux) 33 | SEASONS=(Chaos Discord Confusion Bureaucracy "The Aftermath") 34 | 35 | month_len() 36 | { 37 | case $1 in 38 | 4|6|9|11) 39 | echo 30 40 | ;; 41 | 1|3|5|7|8|10|12) 42 | echo 31 43 | ;; 44 | 2) 45 | if [[ $(($2 % 4)) -eq 0 && $(($2 % 100)) -ne 0 || $(($2 % 400)) -eq 0 ]]; then 46 | echo 29 47 | else 48 | echo 28 49 | fi 50 | esac 51 | } 52 | 53 | ordinal() 54 | { 55 | case ${1:$((${#1}-2)):2} in 56 | [2-9][1]|1 ) echo ${1}st ;; 57 | [2-9][2]|2 ) echo ${1}nd ;; 58 | [2-9][3] ) echo ${1}rd ;; 59 | [1][1-9]|* ) echo ${1}th ;; 60 | esac 61 | } 62 | 63 | ### PROGRAM START ### 64 | 65 | if [ "$1" = "-h" ]; then 66 | echo Usage: $PROGRAM [-h] [MM DD YYYY] 67 | exit 0 68 | fi 69 | 70 | if [ $# -eq 4 ]; then 71 | case $4 in 72 | 1|0) MODE=$4 ;; 73 | esac 74 | elif [ $# -eq 1 ]; then 75 | case $1 in 76 | 1|0) 77 | MODE=$1 78 | shift 79 | ;; 80 | *|" ") 81 | shift 82 | ;; 83 | esac 84 | else 85 | MODE=0 86 | fi 87 | 88 | M=${1:-$(date +%_m)} 89 | [ $M -ne $(date +%_m) ] && MODE=1 90 | D=${2:-$(date +%_d)} 91 | [ $D -ne $(date +%_d) ] && MODE=1 92 | YEAR=${3:-$(date +%Y)} 93 | [ $YEAR -ne $(date +%Y) ] && MODE=1 94 | Y=$(( ${3:-$(date +%Y)} + 1166 )) 95 | 96 | if [ $M -gt 12 ]; then 97 | echo Month out of range 98 | exit 1 99 | fi 100 | 101 | if [ $D -gt $(month_len $M $YEAR) ] || [ $D -le 0 ]; then 102 | echo Day out of range 103 | exit 1 104 | fi 105 | 106 | if [ $(month_len $M $YEAR) -eq 29 ] && [ $M -eq 2 -a $D -eq 29 ]; then 107 | echo "St. Tib's Day, $Y YOLD" 108 | exit 0 109 | fi 110 | 111 | days=$D 112 | 113 | for (( m=1; m<$M; m++ )) 114 | do 115 | ((days+=$(month_len $m $YEAR))) 116 | done 117 | 118 | dayofyear=$days 119 | 120 | if [ $(month_len 2 $YEAR) -eq 29 ] && [ $dayofyear -ge 60 ]; then 121 | ((--dayofyear)) 122 | fi 123 | 124 | seasonday=$(( dayofyear % 73 )) 125 | [ $seasonday -eq 0 ] && seasonday=73 126 | 127 | case $seasonday in 128 | 5) 129 | echo Today is "${APOSTLE[$((dayofyear / 73))]}", in the YOLD $Y 130 | exit 131 | ;; 132 | 50) 133 | echo Today is "${HOLYDAY[$((dayofyear / 73))]}", in the YOLD $Y 134 | exit 135 | ;; 136 | *) 137 | case $dayofyear in 138 | 73|146|219|291|365) 139 | season="${SEASONS[$((dayofyear / 73))-1]}" 140 | ;; 141 | *) 142 | season="${SEASONS[$((dayofyear / 73))]}" 143 | ;; 144 | esac 145 | ;; 146 | esac 147 | 148 | dayofweek="${WEEKDAY[$(( (dayofyear-1)%5))]}" 149 | 150 | case $MODE in 151 | 0) 152 | echo -n "Today is $dayofweek, the $(ordinal $seasonday) " 153 | echo "day of $season in the YOLD $Y" 154 | ;; 155 | 1) 156 | echo "$dayofweek, $season $seasonday, $Y YOLD" 157 | ;; 158 | esac 159 | 160 | ### EOF ### 161 | -------------------------------------------------------------------------------- /rcal/scripts/dday.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby -w 2 | # encoding: utf-8 3 | 4 | require 'calendar' 5 | 6 | year = ARGV[0] ||= Time.now.strftime("%Y").to_i 7 | 8 | # 4/4, 6/6, 8/8, 10/10, 12/12 allways fall on the same day. That day 9 | # is the so-called "Doomsday." 10 | c = Calendar.new(4, 4, year) 11 | a = c.get_day_of_week_name 12 | puts "#{year}'s Doomsday is #{a}" 13 | -------------------------------------------------------------------------------- /rcal/scripts/rcal-funcs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/echo source this file 2 | # 3 | # rcal shell function shortcuts 4 | # 5 | # Note: these functions might override existing programs 6 | # with the same name, so comment out functions 7 | # like cal() if you still want to use the real cal. 8 | # 9 | 10 | cal() { rcal "$@"; } 11 | 12 | ncal() { rcal --ncal "$@"; } 13 | 14 | ddate() { rcal --ddate "$@"; } 15 | 16 | dow() { rcal -D "$@"; } 17 | 18 | html() { 19 | rcal --html "$@" 20 | } 21 | -------------------------------------------------------------------------------- /rcal/scripts/rcalhtml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | 3 | opt="$1" 4 | 5 | browser=/usr/bin/firefox 6 | 7 | [ "$opt" != "-h" ] && unset opt 8 | 9 | calendar="/tmp/rcal-html.html" 10 | rcal $opt --html "$@" > $calendar 11 | $browser "$calendar" 12 | 13 | rm "$calendar" 14 | -------------------------------------------------------------------------------- /rcal/scripts/tcal.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby -w 2 | # encoding: utf-8 3 | 4 | # Show tomorrow's calendar. 5 | 6 | require 'calendar' 7 | 8 | month = Calendar::MONTH.to_i 9 | day = Calendar::DAY.to_i 10 | year = Calendar::YEAR.to_i 11 | 12 | c = Calendar.new(month, day, year) 13 | 14 | if month == 12 && day == 31 15 | c.m = c.d = 1 16 | c.y += 1 17 | elsif day == c.get_month_len.to_i 18 | c.m += 1 19 | c.d = 1 20 | else 21 | c.d += 1 22 | end 23 | 24 | c.print_g_monthly 25 | -------------------------------------------------------------------------------- /rcal/scripts/ycal.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby -w 2 | # encoding: utf-8 3 | 4 | # Show yesderday's calendar. 5 | 6 | require 'calendar' 7 | 8 | month = Calendar::MONTH.to_i 9 | day = Calendar::DAY.to_i 10 | year = Calendar::YEAR.to_i 11 | 12 | c = Calendar.new(month, day, year) 13 | 14 | if month == 1 && day == 1 15 | c.m = 12 16 | c.y -= 1 17 | c.d = 31 18 | elsif day == 1 19 | c.m -= 1 20 | c.d = c.get_month_len.to_i 21 | else 22 | c.d -= 1 23 | end 24 | 25 | c.print_g_monthly 26 | -------------------------------------------------------------------------------- /rcal/tests/weeknum_test.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby -w 2 | # encoding: utf-8 3 | 4 | require 'calendar' 5 | 6 | y = ARGV[0] ||= Calendar::YEAR 7 | 8 | c = Calendar.new(1, nil, y) 9 | 10 | (1..12).each do |mon| 11 | c.m = mon 12 | c.print_weeknums 13 | end 14 | -------------------------------------------------------------------------------- /readme.html: -------------------------------------------------------------------------------- 1 |

lcal - display a calendar

2 |

3 |

DESCRIPTION

4 |

lcal is a command-line calendar similar to cal/ncal. This program produces Gregorian and Julian calendars, an HTML 5 calendar, an ncal formatted calendar, weeknumbers, Discordian dates, dates of Easter (Western, Orthodox, Orthodox-Julian), monthly and yearly calendars, and Julian Day Number conversions.

5 |

USAGE

6 |

lcal [option] [month] [day] [year]

7 |

OPTIONS

8 |
    9 |
  • -d --day-of-week 10 |
      11 |
    • return day of week for date
    • 12 |
  • 13 |
  • -e --easter 14 |
      15 |
    • show the date for Easter (Western)
    • 16 |
  • 17 |
  • -h --no-highlight 18 |
      19 |
    • disable highlighting
    • 20 |
  • 21 |
  • -j --julian 22 |
      23 |
    • show Julian calendar
    • 24 |
  • 25 |
  • -m --month 26 |
      27 |
    • show calendar for month (and year)
    • 28 |
  • 29 |
  • -n --next 30 |
      31 |
    • show next month's calendar
    • 32 |
  • 33 |
  • -o --orthodox 34 |
      35 |
    • show the date for Easter (Orthodox)
    • 36 |
  • 37 |
  • -p --previous 38 |
      39 |
    • show last month's calendar
    • 40 |
  • 41 |
  • -w --week-number 42 |
      43 |
    • Show week number.
    • 44 |
  • 45 |
  • -x --date-diff 46 |
      47 |
    • show time between two dates. This option takes either 3 parameters or 6, as in MM DD YYYY MM DD YYYY or MM DD YYYY. If three, the current date is computed against it; if six, one date is computed against the other.
    • 48 |
  • 49 |
  • -y --year 50 |
      51 |
    • show yearly calendar
    • 52 |
  • 53 |
  • -D --discordian 54 |
      55 |
    • show Discordian date
    • 56 |
  • 57 |
  • -G --gregorian-to-jdn 58 |
      59 |
    • convert Gregorian date to Julian day number
    • 60 |
  • 61 |
  • -H --html 62 |
      63 |
    • generate an html calendar for date
    • 64 |
  • 65 |
  • -J --jdn-to-gregorian 66 |
      67 |
    • convert Julian day number to Gregorian date
    • 68 |
  • 69 |
  • -N --ncal 70 |
      71 |
    • show calendar in ncal mode
    • 72 |
  • 73 |
  • -O --orthodox-julian 74 |
      75 |
    • show the date for Orthodox Easter as Julian date
    • 76 |
  • 77 |
  • -V --version 78 |
      79 |
    • show version information and exit
    • 80 |
  • 81 |
  • -W --show-week-number 82 |
      83 |
    • show week numbers next to calendar
    • 84 |
  • 85 |
  • -1 --one 86 |
      87 |
    • show only the current month. Default
    • 88 |
  • 89 |
  • -3 --three 90 |
      91 |
    • show last, current and next month
    • 92 |
  • 93 |
  • --help 94 |
      95 |
    • show this usage and exit
    • 96 |
  • 97 |
98 |

PARAMETERS

99 |

Most flags can take a date string as an argument. A single parameter is either a month -- this will print the month for the current year -- or it is a year -- this will print the yearly calendar for the specified year. Two parameters are month and year -- this will print the month for the specified year. Three parameters are month, day and year -- this will print the specified calendar with the day highlighted.

100 |

month can be numbers [1-12], or three or more letters of the month name: jan, feb, mar, etc.

101 |

The -m flag is the same as month without the flag. A year can be added after month.

102 |

To disable highlighting for --html, use -h before this flag.

103 |

Flags -1, -n and -p stop reading arguments after them.

104 |

TAB COMPLETION

105 |

Source /scripts/lcal_completion for lcal to support tab completion. The typical location for completion scripts is /etc/bash_completion.d/.

106 |

For current shell:

107 |
cd lcal/scripts
108 | source lcal_completion
109 |

Make permanent:

110 |
cd lcal/scripts
111 | sudo ln -fs "${PWD}"/lcal_completion /etc/bash_completion.d/lcal_completion
112 |

Once sourced, lcal can generate a list of short and long flags.

113 |

For example:

114 |
% lcal - [TAB][TAB]
115 | -1  -3  -d  -D  -e  -G  -h  -H  -j  -J  -m  -n  -N  -o  -O  -p  -V  -w  -W  -x  -y
116 |
% lcal -- [TAB][TAB]
117 | --date-diff          --easter             --html               --month              --no-highlight       --orthodox-julian    --three              --year
118 | --day-of-week        --gregorian-to-jdn   --jdn-to-gregorian   --ncal               --one                --previous           --version
119 | --discordian         --help               --julian             --next               --orthodox           --show-week-numbers  --week-number
120 |

OTHER FILES

121 |
    122 |
  • pc - a perpetual calendar generator.

    123 |

    Using arrays of the 14 possible calendars (7 common years, 7 leap years) and basic functions taken from lcal itself, pc can generate any monthly calendar. It is fast and lightweight, and unlike lcal, pc is compatable with the Korn Shell.

    124 |

    Development scripts for pc can be found in dev/perpetual-scripts

  • 125 |
  • dcal - print the Discordian calendar.

    126 |

    This script prints a formatted calendar based on the Discordian seasons. See the README for dcal for more information.

  • 127 |
128 |

BUGS

129 |

So far, lcal does not account for the Gregorian Reformation. so the year range is currently 1753 - 9999. The algorithm I used for calculating the day of week does not use Julian Day Numbers -- which it should.

130 |

See: BUGS

131 |

VERSION

132 |

1.0.0

133 |

SEE ALSO

134 |

cal, ddate, ncal, gcal, ccal, when

135 |

LICENSE

136 |

(c) 2014-2016 Luciano D. Cecere - ldante86@aol.com

137 | -------------------------------------------------------------------------------- /screenshots/completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/completion.png -------------------------------------------------------------------------------- /screenshots/html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/html.png -------------------------------------------------------------------------------- /screenshots/julian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/julian.png -------------------------------------------------------------------------------- /screenshots/ldoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/ldoc.png -------------------------------------------------------------------------------- /screenshots/ncal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/ncal.png -------------------------------------------------------------------------------- /screenshots/three.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/three.png -------------------------------------------------------------------------------- /screenshots/weeknumers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/weeknumers.png -------------------------------------------------------------------------------- /screenshots/yearly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldante86/lcal/b69de1913e8cb7df94fac732268ee98a25632ab7/screenshots/yearly.png -------------------------------------------------------------------------------- /scripts/doc: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | # PROGRAM: doc.sh 4 | # AUTHOR: Luciano D. Cecere 5 | # YEAR: 2016 6 | # PURPOSE: Extract documentation from script files and create 7 | # a manual. Special comment tags are: 8 | # "#%%" is the header 9 | # "#% " is the body 10 | 11 | FILE="$1" 12 | 13 | if [ -z "$FILE" ] || [ ! -e "$FILE" ]; then 14 | exit 1 15 | fi 16 | 17 | printf "\n%s\n\n" "# Function documentation manual for $FILE" 18 | 19 | while read 20 | do 21 | if [ "${REPLY:0:3}" = "#%%" ]; then 22 | #echo ---------------------------- 23 | echo 24 | echo -n "Function: " 25 | fn=$(echo "${REPLY}" | sed 's/#%% //' | awk '{print $2}') 26 | echo "**${fn}**" 27 | echo 28 | a=$(echo "$REPLY" | sed 's/#%% //') 29 | echo -n "Parameters: " 30 | b=$(echo "$a" | cut -d" " -f 3-) 31 | echo "*${b:-none}*" 32 | fi 33 | 34 | if [ "${REPLY:0:3}" = "#% " ]; then 35 | printf "\n\t" 36 | echo "$REPLY" | sed 's/#% //' | sed 's/purpose: //' 37 | fi 38 | done < "$FILE" 39 | -------------------------------------------------------------------------------- /scripts/doomsday.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | # 4/4, 6/6, 8/8, 10/10, 12/12 and the last day of February allways fall 4 | # on the same day. That day is called "Doomsday" 5 | # 6 | # https://en.wikipedia.org/wiki/Doomsday_rule 7 | # http://homer.freeshell.org/dd.cgi?date=11%2F30%2F2016 8 | # 9 | 10 | y="${1:-$(date +%Y)}" 11 | 12 | days=(Sunday Monday Tuesday Wednesday Thursday Friday Saturday) 13 | 14 | _ddates() 15 | { 16 | case $1 in 17 | 1) echo "3/4" ;; 18 | 2) echo "28/29" ;; 19 | 3) echo 0 ;; 20 | 5) echo 9 ;; 21 | 7) echo 11 ;; 22 | 9) echo 5 ;; 23 | 11) echo 7 ;; 24 | 4|6|8|10|12) echo $1 ;; 25 | esac 26 | 27 | } 28 | 29 | _base_doomsday() 30 | { 31 | case $1 in 32 | 1500|1900|2300) echo 3 ;; 33 | 1600|2000|2400) echo 2 ;; 34 | 1700|2100|2500) echo 0 ;; 35 | 1800|2200|2500) echo 5 ;; 36 | esac 37 | } 38 | 39 | _doomsday() 40 | { 41 | local cent="${1:0:2}00" 42 | 43 | local year="${1:2}" 44 | 45 | local base="$(_base_doomsday $cent)" 46 | 47 | echo $(( (base + year + ( year / 4 )) % 7 )) 48 | 49 | } 50 | 51 | _doomsday_2() 52 | { 53 | local cent="${1:0:2}00" 54 | 55 | local year="${1:2}" 56 | 57 | local base="$(_base_doomsday $cent)" 58 | 59 | local doomsday=$(( base + (((year / 12) + (year % 12) + ((year % 12) / 4)) % 7) )) 60 | 61 | if (( doomsday > 7 )); then 62 | echo $((doomsday - 7)) 63 | else 64 | echo $doomsday 65 | fi 66 | } 67 | -------------------------------------------------------------------------------- /scripts/lcal-funcs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/echo This file must be sourced. 2 | 3 | lmenu() 4 | { 5 | echo "\ 6 | cal date display a calendar 7 | ddate date show Discordian date 8 | dow date show day of week 9 | jdn date show Julian Day Number 10 | jul date show Julian calendar 11 | ncal date display ncal calendar 12 | html date show html calendar 13 | wn date show week number 14 | yy year show yearly calendar\ 15 | " 16 | } 17 | 18 | cal() 19 | { 20 | lcal "$@" 21 | } 22 | 23 | ncal() 24 | { 25 | lcal --ncal "$@" 26 | } 27 | 28 | ddate() 29 | { 30 | lcal --discordian "$@" 31 | } 32 | 33 | html() 34 | { 35 | local browser=firefox 36 | local calendar="/tmp/${RANDOM}.html" 37 | 38 | lcal --html "$@" > "$calendar" 39 | "$browser" "$calendar" 40 | } 41 | 42 | dow() 43 | { 44 | lcal -d "$@" 45 | } 46 | 47 | wn() 48 | { 49 | lcal -w "$@" 50 | } 51 | 52 | yy() 53 | { 54 | lcal -y "$@" 55 | } 56 | 57 | jul() 58 | { 59 | lcal --julian "$@" 60 | } 61 | 62 | jdn() 63 | { 64 | lcal --gregorian-to-jdn "$@" 65 | } 66 | -------------------------------------------------------------------------------- /scripts/lcal_completion: -------------------------------------------------------------------------------- 1 | _lcal() 2 | { 3 | COMPREPLY=() 4 | local word=${COMP_WORDS[COMP_CWORD]} 5 | 6 | local LONG_FLAGS="--day-of-week --easter --no-highlight --julian --month 7 | --next --orthodox --previous --week-number --date-diff 8 | --year --discordian --gregorian-to-jdn --html --jdn-to-gregorian 9 | --ncal --orthodox-julian --version --show-week-numbers 10 | --one --three --help" 11 | 12 | local SHORT_FLAGS="-d -e -h -j -m -n -o -p -w -x -y -D -G -H -J -N -O -V -W -1 -3" 13 | local MONTH_NUMBERS="1 2 3 4 5 6 7 8 9 10 11 12 jan feb mar apr jun jul aug sep oct nov dec" 14 | 15 | case "$word" in 16 | --*) COMPREPLY=( $( compgen -W "$LONG_FLAGS" -- $word) ) 17 | return 0 18 | ;; 19 | 20 | -*) COMPREPLY=( $( compgen -W "$SHORT_FLAGS" -- $word ) ) 21 | return 0 22 | ;; 23 | *) COMPREPLY=( $( compgen -W "$MONTH_NUMBERS" -- $word) ) 24 | return 0 25 | ;; 26 | esac 27 | } && complete -F _lcal lcal_completion lcal 28 | -------------------------------------------------------------------------------- /scripts/ldoc: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | set ../bin/lcal 4 | 5 | if [ ! "$1" ]; then 6 | exit 1 7 | fi 8 | 9 | in_file="$1" 10 | 11 | if [ ! -e "$in_file" ] || [ -d "$in_file" ]; then 12 | exit 1 13 | fi 14 | 15 | egrep -on '[A-Za-z0-9_]+[(]+[)]' "$in_file" >/dev/null || exit 1 16 | 17 | lineno=() 18 | fname=() 19 | comment=() 20 | 21 | echo "" 22 | echo "" 23 | echo "" 24 | echo "" 25 | echo "" 27 | 28 | for i in $(egrep -on '[A-Za-z0-9_]+[(]+[)]' "$in_file" | awk -F ":" '{print $1}') 29 | do 30 | lineno+=( "$i" ) 31 | done 32 | 33 | for i in $(egrep -on '[A-Za-z0-9_]+[(]+[)]' "$in_file" | awk -F ":" '{print $2}') 34 | do 35 | fname+=( "$i" ) 36 | done 37 | 38 | while read 39 | do 40 | if [ "${REPLY:0:3}" = "#%%" ]; then 41 | comment+=( "$(echo $REPLY | sed 's/#%% //' | sed 's/usage: //' | cut -d " " -f 2- )" ) 42 | fi 43 | done < "$in_file" 44 | 45 | 46 | #echo "${comment[@]}" 47 | #exit 48 | #echo "${fname[@]}" | tr -d '()' > file 49 | 50 | n=-1 51 | for i in $(echo "${fname[@]}" | tr -d '()') 52 | do 53 | ((++n)) 54 | echo "" 55 | echo "" 56 | echo "" 57 | echo "" 58 | echo "" 59 | done 60 | 61 | echo "
Functions for $in_fileLine NumberParameters" 26 | echo "
$i${lineno[n]}${comment[n]}
" 62 | 63 | -------------------------------------------------------------------------------- /scripts/lhtml: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | # This script generates and html calendar and displays it in a browser. 4 | 5 | # Usage html.sh [date string] 6 | 7 | #browser=/usr/bin/yelp 8 | browser=/usr/bin/firefox 9 | #browser=/usr/bin/google-chrome 10 | 11 | # These browsers don't interpret CSS, so no bolding. 12 | #browser=w3m 13 | #browser=lynx 14 | 15 | calendar="/tmp/${RANDOM}.html" 16 | ../bin/lcal --html "$@" > "$calendar" 17 | "$browser" "$calendar" 18 | 19 | rm "$calendar" 20 | -------------------------------------------------------------------------------- /scripts/plcal_completion: -------------------------------------------------------------------------------- 1 | _plcal() 2 | { 3 | COMPREPLY=() 4 | local word=${COMP_WORDS[COMP_CWORD]} 5 | 6 | local LONG_FLAGS="--date --help --month" 7 | local SHORT_FLAGS="-b -h -n -p " 8 | 9 | case "$word" in 10 | --*) COMPREPLY=( $( compgen -W "$LONG_FLAGS" -- $word) ) 11 | return 0 12 | ;; 13 | 14 | -*) COMPREPLY=( $( compgen -W "$SHORT_FLAGS" -- $word ) ) 15 | return 0 16 | ;; 17 | esac 18 | } && complete -F _plcal plcal_completion plcal 19 | -------------------------------------------------------------------------------- /scripts/stardate-month.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | # 3 | # SCRIPT: stardate-month.sh 4 | # AUTHOR: Luciano D. Cecere 5 | # DATE: 02/01/2018-03:21:18 AM 6 | ######################################################################## 7 | # 8 | # stardate-month.sh - Print stardate for month/year 9 | # Copyright (C) 2018 Luciano D. Cecere 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | # 24 | ######################################################################## 25 | 26 | m=${1:-$(date +%_m)} 27 | y=${2:-$(date +%Y)} 28 | 29 | if (( $y % 4 == 0 )) && (( $y % 100 != 0 )) || (( $y % 400 == 0 )); then 30 | len=("" 31 29 31 30 31 30 31 31 30 31 30 31) 31 | else 32 | len=("" 31 28 31 30 31 30 31 31 30 31 30 31) 33 | fi 34 | 35 | printf "%s | %s\n" "Earth Date" "Star Date" 36 | 37 | for ((d=1; d<=${len[m]}; d++)) 38 | do 39 | echo -n "$m $d $y | " 40 | perl stardate.pl $m $d $y | awk -F" " '{print $4}' 41 | done 42 | 43 | echo 44 | -------------------------------------------------------------------------------- /scripts/stardate.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Script: stardate.pl 4 | # Author: Luciano D. Cecere 5 | # Year: 2018 6 | # License: GPLv2 7 | 8 | # This script converts a Gregorian date to Star Trek's Stardate. 9 | 10 | use strict; 11 | use warnings; 12 | use 5.010; 13 | use POSIX qw(strftime); 14 | 15 | my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec ); 16 | my @month_length = (); 17 | my $year_len; 18 | 19 | my $month = strftime "%m", localtime; 20 | my $day = strftime "%d", localtime; 21 | my $year = strftime "%Y", localtime; 22 | 23 | # Starting date is based on Star Trek: The Next Generation, Gregorian 24 | # year 2323. 25 | my $b = 2323; 26 | my $c = 00000.00; 27 | 28 | sub month_array { 29 | my $y = $_[0]; 30 | if ( ( $y % 4 == 0 and $y % 100 != 0 ) or $y % 400 == 0 ) { 31 | @month_length = qw( 31 29 31 30 31 30 31 31 30 31 30 31 ); 32 | $year_len = 366; 33 | } 34 | else { 35 | @month_length = qw( 31 28 31 30 31 30 31 31 30 31 30 31 ); 36 | $year_len = 365; 37 | } 38 | } 39 | 40 | sub gregorian_to_stardate { 41 | my ( $month, $day, $year ) = @_; 42 | my %mon = (); 43 | 44 | month_array($year); 45 | 46 | my $len = 0; 47 | my $x = 1; 48 | $mon{0} = 0; 49 | foreach my $m (@month_length) { 50 | $mon{$x} = $len += $m; 51 | $x++; 52 | } 53 | 54 | my $stardate = 55 | $c + 56 | ( 1000 * ( $year - $b ) ) + 57 | ( ( 1000 / $year_len ) * ( $mon{ $month - 1 } + $day - 1 ) ); 58 | 59 | $stardate = sprintf( "%.2f", $stardate ); 60 | 61 | print "Captain\'s log, stardate $stardate\n"; 62 | 63 | } 64 | 65 | if ( @ARGV and @ARGV % 3 == 0 ) { 66 | gregorian_to_stardate(@ARGV); 67 | } 68 | elsif ( @ARGV and @ARGV % 3 != 0 ) { 69 | die "Usage: stardate.pl month day year\n"; 70 | } 71 | elsif ( not @ARGV ) { 72 | gregorian_to_stardate( $month, $day, $year ); 73 | } 74 | -------------------------------------------------------------------------------- /scripts/weeknum_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash - 2 | 3 | for i in {1..12} 4 | do 5 | ../bin/lcal -W $i $1 6 | done 7 | --------------------------------------------------------------------------------