mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.0t7
This commit is contained in:
@@ -44,7 +44,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
|
||||
test2700.cal test3100.cal test3300.cal test3400.cal prompt.cal \
|
||||
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
|
||||
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
||||
randomrun.cal xx_print.cal natnumset.cal
|
||||
randomrun.cal xx_print.cal natnumset.cal qtime.cal
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
|
@@ -311,6 +311,13 @@ psqrt.cal
|
||||
Calculate square roots modulo a prime
|
||||
|
||||
|
||||
qtime.cal
|
||||
|
||||
qtime(utc_hr_offset)
|
||||
|
||||
Print the time as English sentence given the hours offset from UTC.
|
||||
|
||||
|
||||
quat.cal
|
||||
|
||||
quat(a, b, c, d)
|
||||
|
60
lib/qtime.cal
Normal file
60
lib/qtime.cal
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* qtime - Display time as English sentence
|
||||
*
|
||||
* usage:
|
||||
* qtime(utc_hr_offset)
|
||||
*
|
||||
* utc_hr_offset Offset from UTC in hours.
|
||||
*
|
||||
* Written by: Klaus Alexander Seistrup <kseis@magnetic-ink.dk>
|
||||
* With minor mods by: Landon Curt Noll <chongo@toad.com>
|
||||
*
|
||||
* See:
|
||||
* http://www.magnetic-ink.dk/download/qtime.html
|
||||
*
|
||||
* for examples of qtime() written on other languages.
|
||||
*/
|
||||
|
||||
/*
|
||||
* qtime - Display time as English sentence
|
||||
*/
|
||||
define qtime(utc_hr_offset)
|
||||
{
|
||||
static mat hr[12] = {
|
||||
"twelve", "one", "two", "three", "four", "five",
|
||||
"six", "seven", "eight", "nine", "ten", "eleven"
|
||||
};
|
||||
static mat mn[7] = {
|
||||
"", "five ", "ten ", "a quarter ", "twenty ", "twenty-five ", "half "
|
||||
};
|
||||
static mat ny[5] = {
|
||||
"nearly ", "almost ", "", "just after ", "after "
|
||||
};
|
||||
static mat up[3] = {
|
||||
"to ", "", "past "
|
||||
};
|
||||
local adj_mins = (((time() + utc_hr_offset*3600) % 86400) + 30) // 60 + 27;
|
||||
local hours = (adj_mins // 60) % 12;
|
||||
local minutes = adj_mins % 60;
|
||||
local almost = minutes % 5;
|
||||
local divisions = (minutes // 5) - 5;
|
||||
local to_past_idx = divisions > 0 ? 1 : 0;
|
||||
|
||||
if (divisions < 0) {
|
||||
divisions = -divisions;
|
||||
to_past_idx = -1;
|
||||
}
|
||||
++to_past_idx;
|
||||
|
||||
/*
|
||||
* Print the English sentence
|
||||
*
|
||||
* We avoid forward and back quotes just to show that the char()
|
||||
* builtin function can be used in conjunction with a printf.
|
||||
*/
|
||||
printf("It%cs %s%s%s%s",
|
||||
char(0x27), ny[almost], mn[divisions], up[to_past_idx], hr[hours]);
|
||||
if (divisions == 0)
|
||||
printf(" o%cclock", char(0x27));
|
||||
printf (".\n");
|
||||
}
|
@@ -22,7 +22,7 @@ prob = 0; /* clear problem counter */
|
||||
|
||||
global junk; /* throw away value */
|
||||
junk = errcount(0); /* clear error count */
|
||||
junk = errmax(0x7fffffff); /* set maximum error very high */
|
||||
junk = errmax(-1); /* prevent errcount from abouting */
|
||||
|
||||
global ecnt; /* expected value of errcount() */
|
||||
ecnt = 0; /* clear expected errcount() value */
|
||||
@@ -7468,7 +7468,9 @@ read -once unitfrac;
|
||||
print '9826: read -once unitfrac';
|
||||
read -once varargs;
|
||||
print '9827: read -once varargs';
|
||||
print '9828: Ending read of selected calc libs';
|
||||
read -once qtime;
|
||||
print '9828: read -once qtime';
|
||||
print '9829: Ending read of selected calc libs';
|
||||
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user