public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0000] pull: cal the branch four
@ 2013-05-26  9:14 Sami Kerola
  2013-05-26  9:14 ` [PATCH 1/4] cal: use Claus Tøndering's day of the week algorithm Sami Kerola
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-26  9:14 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Hi Karel and others,

The cal branch I have in my git has got fixes to issues reviewed earlier,
and I hope all works.  Based on that I decided to get rid of upper cal
year limit, 9999, and replace it with unsigned long.  I know the change
does not make much practical sense, the point of the change is that where
there is no need to have artificial limits to a random magic number they
should not exist.

Assuming the patch series are applied at somepoint I think the next thing
to do for this command is the cal_context Karel proposed[1].  Having more
sensible way to pass run time configuration will hopefully make
implementing the week numbering column easy (which I originally wanted),
and may even make various color additions possible.  Meanwhile here comes
mostly old patch series, with couple new changes.

[1] http://www.spinics.net/lists/util-linux-ng/msg07983.html


The following changes since commit ef264c830effc91add6da334204215f61eb8515e:

  agetty: allow full control on CLOCAL flag (2013-05-23 09:47:58 +0200)

are available in the git repository at:

  git://github.com/kerolasa/lelux-utiliteetit.git cal-fourth

for you to fetch changes up to 3f5e9ecbf54213867ec787f40bd23d76d43dbd61:

  docs: cal: stop telling year 9999 is upper limit (2013-05-26 09:59:21 +0100)

----------------------------------------------------------------
Sami Kerola (18):
      cal: fix preprocessor directive indendation
      cal: convert function like definitions to functions
      cal: clean up use of constants
      tests: add calendar reformation check
      cal: simplify calendar reformat calculations
      cal: remove unnecessary initializations
      cal: de-duplicate julian specific functions
      cal: support --color[={auto,always,never}]
      cal: add --color to usage()
      docs: cal: add --color option description to manual page
      tests: add cal day color corner cases
      cal: stop trimming whitespaces
      cal: mark all functions static
      cal: simplify day_in_week() calculation
      cal: use Claus Tøndering's day of the week algorithm
      cal: remove arbitrary limit of maxium year being 9999
      tests: check cal works when year is far in future
      docs: cal: stop telling year 9999 is upper limit

 misc-utils/Makemodule.am   |   2 +-
 misc-utils/cal.1           |  16 +-
 misc-utils/cal.c           | 611 +++++++++++++++++++++++----------------------
 tests/expected/cal/1m      |  48 ++--
 tests/expected/cal/3m      |  48 ++--
 tests/expected/cal/bigyear | 206 +++++++++++++++
 tests/expected/cal/color   |  55 ++++
 tests/expected/cal/sep1752 | 198 +++++++++++++++
 tests/expected/cal/year    | 240 +++++++++---------
 tests/ts/cal/bigyear       |  95 +++++++
 tests/ts/cal/color         |  68 +++++
 tests/ts/cal/sep1752       |  95 +++++++
 12 files changed, 1211 insertions(+), 471 deletions(-)
 create mode 100644 tests/expected/cal/bigyear
 create mode 100644 tests/expected/cal/color
 create mode 100644 tests/expected/cal/sep1752
 create mode 100755 tests/ts/cal/bigyear
 create mode 100755 tests/ts/cal/color
 create mode 100755 tests/ts/cal/sep1752



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] cal: use Claus Tøndering's day of the week algorithm
  2013-05-26  9:14 [PATCH 0000] pull: cal the branch four Sami Kerola
@ 2013-05-26  9:14 ` Sami Kerola
  2013-05-26  9:14 ` [PATCH 2/4] cal: remove arbitrary limit of maxium year being 9999 Sami Kerola
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-26  9:14 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Reference: http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#T.C3.B8ndering.27s_algorithm
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/cal.c | 50 ++++++++++++++++++++------------------------------
 1 file changed, 20 insertions(+), 30 deletions(-)

diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 4d45145..9575db4 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -234,8 +234,6 @@ int julian;
 
 /* function prototypes */
 static int leap_year(int year);
-static int centuries_since_1700(int year, int centuries);
-static int leap_years_since_year_1(int year);
 static char * ascii_day(char *, int);
 static int center_str(const char* src, char* dest, size_t dest_size, size_t width);
 static void center(const char *, size_t, int);
@@ -427,22 +425,6 @@ static int leap_year(int year)
 		return ( !(year % 4) && (year % 100) ) || !(year % 400);
 }
 
-/* number of centuries since 1700 */
-static int centuries_since_1700(int year, int n)
-{
-	if (year < REFORMATION_YEAR)
-		return 0;
-	else
-		return ((year / (100 * n)) - ((REFORMATION_YEAR / 100) / n));
-}
-
-/* number of leap years between year 1 and this year, not inclusive */
-static int leap_years_since_year_1(int year)
-{
-	return (year / 4 - centuries_since_1700(year, 1) +
-		centuries_since_1700(year, 4));
-}
-
 static void headers_init(int julian)
 {
 	int i, wd, spaces = julian ? J_DAY_LEN - 1 : DAY_LEN - 1;
@@ -681,18 +663,26 @@ day_in_year(int day, int month, int year) {
  *	during the period of 11 days.
  */
 static int
-day_in_week(int day, int month, int year) {
-	long temp;
-
-	temp =
-	    (long)(year - SMALLEST_YEAR) * DAYS_IN_YEAR +
-	    leap_years_since_year_1(year - SMALLEST_YEAR)
-	    + day_in_year(day, month, year);
-	if (temp < FIRST_MISSING_DAY)
-		return ((temp + (FIRST_WEEKDAY - 1)) % DAYS_IN_WEEK);
-	if (temp >= (FIRST_MISSING_DAY + NUMBER_MISSING_DAYS))
-		return ((temp + (FIRST_WEEKDAY - 1 - NUMBER_MISSING_DAYS)) % DAYS_IN_WEEK);
-	return (NONEDAY);
+day_in_week(int d, int m, int y)
+{
+	static const int reform[] = {
+		SUNDAY, WEDNESDAY, TUESDAY, FRIDAY, SUNDAY, WEDNESDAY,
+		FRIDAY, MONDAY, THURSDAY, SATURDAY, TUESDAY, THURSDAY
+	};
+	static const int old[] = {
+		FRIDAY, MONDAY, SUNDAY, WEDNESDAY, FRIDAY, MONDAY,
+		WEDNESDAY, SATURDAY, TUESDAY, THURSDAY, SUNDAY, TUESDAY
+	};
+	if (y != 1753)
+		y -= m < 3;
+	else
+		y -= (m < 3) + 14;
+	if (1752 < y || (y == 1752 && 9 < m) || (y == 1752 && m == 9 && 13 < d))
+		return (y + (y / 4) - (y / 100) + (y / 400) + reform[m - 1] +
+			d) % 7;
+	if (y < 1752 || (y == 1752 && m < 9) || (y == 1752 && m == 9 && d < 3))
+		return (y + y / 4 + old[m - 1] + d) % 7;
+	return NONEDAY;
 }
 
 static char *
-- 
1.8.2.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] cal: remove arbitrary limit of maxium year being 9999
  2013-05-26  9:14 [PATCH 0000] pull: cal the branch four Sami Kerola
  2013-05-26  9:14 ` [PATCH 1/4] cal: use Claus Tøndering's day of the week algorithm Sami Kerola
@ 2013-05-26  9:14 ` Sami Kerola
  2013-05-26  9:14 ` [PATCH 3/4] tests: check cal works when year is far in future Sami Kerola
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-26  9:14 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

The change limits year to be unsigned long. In case a year + month name
exceed a column width two lines are used for them.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/cal.c | 122 ++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 81 insertions(+), 41 deletions(-)

diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 9575db4..84fa4d2 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -177,7 +177,6 @@ enum {
 #define	SPACE			-1		/* used in day array */
 
 #define SMALLEST_YEAR		1
-#define GREATEST_YEAR		9999
 
 #define	DAY_LEN			3		/* 3 spaces per day */
 #define	WEEK_LEN		(DAYS_IN_WEEK * DAY_LEN)
@@ -191,7 +190,7 @@ enum {
 
 #define TODAY_FLAG		0x400		/* flag day for highlighting */
 
-#define FMT_ST_LINES 8
+#define FMT_ST_LINES 9
 #define FMT_ST_CHARS 300	/* 90 suffices in most locales */
 struct fmt_st
 {
@@ -233,17 +232,18 @@ int weekstart = SUNDAY;
 int julian;
 
 /* function prototypes */
-static int leap_year(int year);
+static int leap_year(unsigned long year);
 static char * ascii_day(char *, int);
 static int center_str(const char* src, char* dest, size_t dest_size, size_t width);
 static void center(const char *, size_t, int);
-static void day_array(int, int, int, int *);
+static void day_array(int, int, unsigned long, int *);
 static int day_in_week(int, int, int);
-static int day_in_year(int, int, int);
-static void yearly(int, int, int);
-static void do_monthly(int, int, int, struct fmt_st*);
-static void monthly(int, int, int);
-static void monthly3(int, int, int);
+static int day_in_year(int, int, unsigned long);
+static void yearly(int, unsigned long, int);
+static int do_monthly(int, int, unsigned long, struct fmt_st*, int);
+static void monthly(int, int, unsigned long);
+static int two_header_lines(int month, unsigned long year);
+static void monthly3(int, int, unsigned long);
 static void __attribute__ ((__noreturn__)) usage(FILE * out);
 static void headers_init(int);
 
@@ -251,7 +251,8 @@ int
 main(int argc, char **argv) {
 	struct tm *local_time;
 	time_t now;
-	int ch, day = 0, month = 0, year = 0, yflag = 0;
+	int ch, day = 0, month = 0, yflag = 0;
+	unsigned long year;
 	int num_months = NUM_MONTHS;
 	int colormode = UL_COLORMODE_AUTO;
 
@@ -379,15 +380,15 @@ main(int argc, char **argv) {
 			errx(EXIT_FAILURE, _("illegal month value: use 1-12"));
 		/* FALLTHROUGH */
 	case 1:
-		year = strtos32_or_err(*argv++, _("illegal year value: use 1-9999"));
-		if (year < SMALLEST_YEAR || GREATEST_YEAR < year)
-			errx(EXIT_FAILURE, _("illegal year value: use 1-9999"));
+		year = strtoul_or_err(*argv++, _("illegal year value: use positive integer"));
+		if (year < SMALLEST_YEAR)
+			errx(EXIT_FAILURE, _("illegal year value: use positive integer"));
 		if (day) {
 			int dm = days_in_month[leap_year(year)][month];
 			if (day > dm)
 				errx(EXIT_FAILURE, _("illegal day value: use 1-%d"), dm);
 			day = day_in_year(day, month, year);
-		} else if ((local_time->tm_year + 1900) == year) {
+		} else if ((unsigned long) (local_time->tm_year + 1900) == year) {
 			day = local_time->tm_yday + 1;
 		}
 		if (!month)
@@ -417,7 +418,7 @@ main(int argc, char **argv) {
 }
 
 /* leap year -- account for gregorian reformation in 1752 */
-static int leap_year(int year)
+static int leap_year(unsigned long year)
 {
 	if (year <= REFORMATION_YEAR)
 		return !(year % 4);
@@ -449,11 +450,13 @@ static void headers_init(int julian)
 		full_month[i] = nl_langinfo(MON_1 + i);
 }
 
-static void
-do_monthly(int day, int month, int year, struct fmt_st *out) {
+static int
+do_monthly(int day, int month, unsigned long year, struct fmt_st *out, int header_hint) {
 	int col, row, days[MAXDAYS];
 	char *p, lineout[FMT_ST_CHARS];
-	int width = (julian ? J_WEEK_LEN : WEEK_LEN) - 1;
+	size_t width = (julian ? J_WEEK_LEN : WEEK_LEN) - 1;
+	size_t len;
+	int pos = 0;
 
 	day_array(day, month, year, days);
 
@@ -463,11 +466,23 @@ do_monthly(int day, int month, int year, struct fmt_st *out) {
 	 * Basque the translation should be: "%2$dko %1$s", and
 	 * the Vietnamese should be "%s na(m %d", etc.
 	 */
-	snprintf(lineout, sizeof(lineout), _("%s %d"),
+	if (header_hint < 0)
+		header_hint = two_header_lines(month, year);
+	if (header_hint) {
+		snprintf(lineout, sizeof(lineout), _("%s"), full_month[month - 1]);
+		center_str(lineout, out->s[pos], ARRAY_SIZE(out->s[pos]), width);
+		pos++;
+		snprintf(lineout, sizeof(lineout), _("%lu"), year);
+		center_str(lineout, out->s[pos], ARRAY_SIZE(out->s[pos]), width);
+		pos++;
+	} else {
+		snprintf(lineout, sizeof(lineout), _("%s %lu"),
 			full_month[month - 1], year);
-	center_str(lineout, out->s[0], ARRAY_SIZE(out->s[0]), width);
+		center_str(lineout, out->s[pos], ARRAY_SIZE(out->s[pos]), width);
+		pos++;
+	}
 
-	snprintf(out->s[1], FMT_ST_CHARS, "%s", day_headings);
+	snprintf(out->s[pos++], FMT_ST_CHARS, "%s", day_headings);
 	for (row = 0; row < DAYS_IN_WEEK - 1; row++) {
 		int has_hl = 0;
 		for (col = 0, p = lineout; col < DAYS_IN_WEEK; col++) {
@@ -477,35 +492,54 @@ do_monthly(int day, int month, int year, struct fmt_st *out) {
 			p = ascii_day(p, xd);
 		}
 		*p = '\0';
-		snprintf(out->s[row+2], FMT_ST_CHARS, "%s", lineout);
+		snprintf(out->s[row+pos], FMT_ST_CHARS, "%s", lineout);
 		if (has_hl)
-			Hrow = out->s[row+2];
+			Hrow = out->s[row+pos];
 	}
+	pos += row;
+	return pos;
 }
 
 static void
-monthly(int day, int month, int year) {
-	int i;
+monthly(int day, int month, unsigned long year) {
+	int i, rows;
 	struct fmt_st out;
 
-	do_monthly(day, month, year, &out);
-	for (i = 0; i < FMT_ST_LINES; i++) {
+	rows = do_monthly(day, month, year, &out, -1);
+	for (i = 0; i < rows; i++) {
 		my_putstring(out.s[i]);
 		my_putstring("\n");
 	}
 }
 
+static int
+two_header_lines(int month, unsigned long year)
+{
+	char lineout[FMT_ST_CHARS];
+	size_t width = (julian ? J_WEEK_LEN : WEEK_LEN) - 1;
+	size_t len;
+	snprintf(lineout, sizeof(lineout), "%lu", year);
+	len = strlen(lineout);
+	len += strlen(full_month[month - 1]) + 1;
+	if (width < len)
+		return 1;
+	return 0;
+}
+
 static void
-monthly3(int day, int month, int year) {
+monthly3(int day, int month, unsigned long year) {
 	char lineout[FMT_ST_CHARS];
 	int i;
-	int width;
+	int width, rows, r, two_lines;
 	struct fmt_st out_prev;
 	struct fmt_st out_curm;
 	struct fmt_st out_next;
-	int prev_month, prev_year;
-	int next_month, next_year;
+	int prev_month, next_month;
+	unsigned long prev_year, next_year;
 
+	memset(&out_prev, 0, sizeof(struct fmt_st));
+	memset(&out_curm, 0, sizeof(struct fmt_st));
+	memset(&out_next, 0, sizeof(struct fmt_st));
 	if (month == 1) {
 		prev_month = MONTHS_IN_YEAR;
 		prev_year  = year - 1;
@@ -520,18 +554,24 @@ monthly3(int day, int month, int year) {
 		next_month = month + 1;
 		next_year  = year;
 	}
-
-	do_monthly(day, prev_month, prev_year, &out_prev);
-	do_monthly(day, month,      year,      &out_curm);
-	do_monthly(day, next_month, next_year, &out_next);
+	two_lines = two_header_lines(prev_month, prev_year);
+	two_lines += two_header_lines(month, year);
+	two_lines += two_header_lines(next_month, next_year);
+	if (0 < two_lines)
+		rows = FMT_ST_LINES;
+	else
+		rows = FMT_ST_LINES - 1;
+	do_monthly(day, prev_month, prev_year, &out_prev, two_lines);
+	do_monthly(day, month,      year,      &out_curm, two_lines);
+	do_monthly(day, next_month, next_year, &out_next, two_lines);
 
 	width = (julian ? J_WEEK_LEN : WEEK_LEN) -1;
-	for (i = 0; i < 2; i++) {
+	for (i = 0; i < (two_lines ? 3 : 2); i++) {
 		snprintf(lineout, sizeof(lineout),
 			"%s  %s  %s\n", out_prev.s[i], out_curm.s[i], out_next.s[i]);
 		my_putstring(lineout);
 	}
-	for (i = 2; i < FMT_ST_LINES; i++) {
+	for (i = two_lines ? 3 : 2; i < rows; i++) {
 		int w1, w2, w3;
 		w1 = w2 = w3 = width;
 
@@ -551,7 +591,7 @@ monthly3(int day, int month, int year) {
 }
 
 static void
-yearly(int day, int year, int julian) {
+yearly(int day, unsigned long year, int julian) {
 	int col, *dp, i, month, row, which_cal;
 	int maxrow, sep_len, week_len;
 	int days[MONTHS_IN_YEAR][MAXDAYS];
@@ -566,7 +606,7 @@ yearly(int day, int year, int julian) {
 		sep_len = HEAD_SEP;
 		week_len = WEEK_LEN;
 	}
-	snprintf(lineout, sizeof(lineout), "%d", year);
+	snprintf(lineout, sizeof(lineout), "%lu", year);
 	/* 2013-04-28: The -1 near sep_len makes year header to be
 	 * aligned exactly how it has been aligned for long time, but it
 	 * is unexplainable.  */
@@ -615,7 +655,7 @@ yearly(int day, int year, int julian) {
  *	builds that array for any month from Jan. 1 through Dec. 9999.
  */
 static void
-day_array(int day, int month, int year, int *days) {
+day_array(int day, int month, unsigned long year, int *days) {
 	int julday, daynum, dw, dm;
 	int *sep1752;
 
@@ -646,7 +686,7 @@ day_array(int day, int month, int year, int *days) {
  *	return the 1 based day number within the year
  */
 static int
-day_in_year(int day, int month, int year) {
+day_in_year(int day, int month, unsigned long year) {
 	int i, leap;
 
 	leap = leap_year(year);
-- 
1.8.2.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] tests: check cal works when year is far in future
  2013-05-26  9:14 [PATCH 0000] pull: cal the branch four Sami Kerola
  2013-05-26  9:14 ` [PATCH 1/4] cal: use Claus Tøndering's day of the week algorithm Sami Kerola
  2013-05-26  9:14 ` [PATCH 2/4] cal: remove arbitrary limit of maxium year being 9999 Sami Kerola
@ 2013-05-26  9:14 ` Sami Kerola
  2013-05-26  9:14 ` [PATCH 4/4] docs: cal: stop telling year 9999 is upper limit Sami Kerola
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-26  9:14 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 tests/expected/cal/bigyear | 206 +++++++++++++++++++++++++++++++++++++++++++++
 tests/ts/cal/bigyear       |  95 +++++++++++++++++++++
 2 files changed, 301 insertions(+)
 create mode 100644 tests/expected/cal/bigyear
 create mode 100755 tests/ts/cal/bigyear

diff --git a/tests/expected/cal/bigyear b/tests/expected/cal/bigyear
new file mode 100644
index 0000000..dec7949
--- /dev/null
+++ b/tests/expected/cal/bigyear
@@ -0,0 +1,206 @@
+
+Gregorian - Monday-based month
+      December      
+12345678901234567890
+Mo Tu We Th Fr Sa Su
+             1  2  3 
+ 4  5  6  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 
+                     
+Gregorian - Sunday-based month
+      December      
+12345678901234567890
+Su Mo Tu We Th Fr Sa
+                1  2 
+ 3  4  5  6  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                   
+Julian - Monday-based month
+          December         
+    12345678901234567890   
+Mon Tue Wed Thu Fri Sat Sun
+                335 336 337 
+338 339 340 341 342 343 344 
+345 346 347 348 349 350 351 
+352 353 354 355 356 357 358 
+359 360 361 362 363 364 365 
+                            
+Julian - Sunday-based month
+          December         
+    12345678901234567890   
+Sun Mon Tue Wed Thu Fri Sat
+                    335 336 
+337 338 339 340 341 342 343 
+344 345 346 347 348 349 350 
+351 352 353 354 355 356 357 
+358 359 360 361 362 363 364 
+365                         
+Gregorian - Monday-based three months
+      November              December               January      
+12345678901234567890  12345678901234567890  12345678901234567891
+Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
+       1  2  3  4  5               1  2  3   1  2  3  4  5  6  7 
+ 6  7  8  9 10 11 12   4  5  6  7  8  9 10   8  9 10 11 12 13 14 
+13 14 15 16 17 18 19  11 12 13 14 15 16 17  15 16 17 18 19 20 21 
+20 21 22 23 24 25 26  18 19 20 21 22 23 24  22 23 24 25 26 27 28 
+27 28 29 30           25 26 27 28 29 30 31  29 30 31             
+                                                                 
+Gregorian - Sunday-based three months
+      November              December               January      
+12345678901234567890  12345678901234567890  12345678901234567891
+Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
+          1  2  3  4                  1  2      1  2  3  4  5  6 
+ 5  6  7  8  9 10 11   3  4  5  6  7  8  9   7  8  9 10 11 12 13 
+12 13 14 15 16 17 18  10 11 12 13 14 15 16  14 15 16 17 18 19 20 
+19 20 21 22 23 24 25  17 18 19 20 21 22 23  21 22 23 24 25 26 27 
+26 27 28 29 30        24 25 26 27 28 29 30  28 29 30 31          
+                      31                                         
+Julian - Monday-based three months
+          November                     December                     January          
+    12345678901234567890         12345678901234567890         12345678901234567891   
+Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun
+        305 306 307 308 309                  335 336 337    1   2   3   4   5   6   7 
+310 311 312 313 314 315 316  338 339 340 341 342 343 344    8   9  10  11  12  13  14 
+317 318 319 320 321 322 323  345 346 347 348 349 350 351   15  16  17  18  19  20  21 
+324 325 326 327 328 329 330  352 353 354 355 356 357 358   22  23  24  25  26  27  28 
+331 332 333 334              359 360 361 362 363 364 365   29  30  31                 
+                                                                                      
+Julian - Sunday-based three months
+          November                     December                     January          
+    12345678901234567890         12345678901234567890         12345678901234567891   
+Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat
+            305 306 307 308                      335 336        1   2   3   4   5   6 
+309 310 311 312 313 314 315  337 338 339 340 341 342 343    7   8   9  10  11  12  13 
+316 317 318 319 320 321 322  344 345 346 347 348 349 350   14  15  16  17  18  19  20 
+323 324 325 326 327 328 329  351 352 353 354 355 356 357   21  22  23  24  25  26  27 
+330 331 332 333 334          358 359 360 361 362 363 364   28  29  30  31             
+                             365                                                      
+Gregorian - Monday-based year
+                       12345678901234567890                       
+
+       January               February                 March       
+Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su
+                   1          1  2  3  4  5          1  2  3  4  5   
+ 2  3  4  5  6  7  8    6  7  8  9 10 11 12    6  7  8  9 10 11 12   
+ 9 10 11 12 13 14 15   13 14 15 16 17 18 19   13 14 15 16 17 18 19   
+16 17 18 19 20 21 22   20 21 22 23 24 25 26   20 21 22 23 24 25 26   
+23 24 25 26 27 28 29   27 28                  27 28 29 30 31         
+30 31                                                                
+        April                   May                   June        
+Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su
+                1  2    1  2  3  4  5  6  7             1  2  3  4   
+ 3  4  5  6  7  8  9    8  9 10 11 12 13 14    5  6  7  8  9 10 11   
+10 11 12 13 14 15 16   15 16 17 18 19 20 21   12 13 14 15 16 17 18   
+17 18 19 20 21 22 23   22 23 24 25 26 27 28   19 20 21 22 23 24 25   
+24 25 26 27 28 29 30   29 30 31               26 27 28 29 30         
+                                                                     
+        July                  August                September     
+Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su
+                1  2       1  2  3  4  5  6                1  2  3   
+ 3  4  5  6  7  8  9    7  8  9 10 11 12 13    4  5  6  7  8  9 10   
+10 11 12 13 14 15 16   14 15 16 17 18 19 20   11 12 13 14 15 16 17   
+17 18 19 20 21 22 23   21 22 23 24 25 26 27   18 19 20 21 22 23 24   
+24 25 26 27 28 29 30   28 29 30 31            25 26 27 28 29 30      
+31                                                                   
+       October               November               December      
+Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su   Mo Tu We Th Fr Sa Su
+                   1          1  2  3  4  5                1  2  3   
+ 2  3  4  5  6  7  8    6  7  8  9 10 11 12    4  5  6  7  8  9 10   
+ 9 10 11 12 13 14 15   13 14 15 16 17 18 19   11 12 13 14 15 16 17   
+16 17 18 19 20 21 22   20 21 22 23 24 25 26   18 19 20 21 22 23 24   
+23 24 25 26 27 28 29   27 28 29 30            25 26 27 28 29 30 31   
+30 31                                                                
+
+Gregorian - Sunday-based year
+                       12345678901234567890                       
+
+       January               February                 March       
+Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
+ 1  2  3  4  5  6  7             1  2  3  4             1  2  3  4   
+ 8  9 10 11 12 13 14    5  6  7  8  9 10 11    5  6  7  8  9 10 11   
+15 16 17 18 19 20 21   12 13 14 15 16 17 18   12 13 14 15 16 17 18   
+22 23 24 25 26 27 28   19 20 21 22 23 24 25   19 20 21 22 23 24 25   
+29 30 31               26 27 28               26 27 28 29 30 31      
+                                                                     
+        April                   May                   June        
+Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
+                   1       1  2  3  4  5  6                1  2  3   
+ 2  3  4  5  6  7  8    7  8  9 10 11 12 13    4  5  6  7  8  9 10   
+ 9 10 11 12 13 14 15   14 15 16 17 18 19 20   11 12 13 14 15 16 17   
+16 17 18 19 20 21 22   21 22 23 24 25 26 27   18 19 20 21 22 23 24   
+23 24 25 26 27 28 29   28 29 30 31            25 26 27 28 29 30      
+30                                                                   
+        July                  August                September     
+Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
+                   1          1  2  3  4  5                   1  2   
+ 2  3  4  5  6  7  8    6  7  8  9 10 11 12    3  4  5  6  7  8  9   
+ 9 10 11 12 13 14 15   13 14 15 16 17 18 19   10 11 12 13 14 15 16   
+16 17 18 19 20 21 22   20 21 22 23 24 25 26   17 18 19 20 21 22 23   
+23 24 25 26 27 28 29   27 28 29 30 31         24 25 26 27 28 29 30   
+30 31                                                                
+       October               November               December      
+Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
+ 1  2  3  4  5  6  7             1  2  3  4                   1  2   
+ 8  9 10 11 12 13 14    5  6  7  8  9 10 11    3  4  5  6  7  8  9   
+15 16 17 18 19 20 21   12 13 14 15 16 17 18   10 11 12 13 14 15 16   
+22 23 24 25 26 27 28   19 20 21 22 23 24 25   17 18 19 20 21 22 23   
+29 30 31               26 27 28 29 30         24 25 26 27 28 29 30   
+                                              31                     
+
+Julian - Monday-based year
+                   12345678901234567890                  
+
+          January                       February         
+Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
+                          1            32  33  34  35  36   
+  2   3   4   5   6   7   8    37  38  39  40  41  42  43   
+  9  10  11  12  13  14  15    44  45  46  47  48  49  50   
+ 16  17  18  19  20  21  22    51  52  53  54  55  56  57   
+ 23  24  25  26  27  28  29    58  59                       
+ 30  31                                                     
+           March                         April           
+Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
+         60  61  62  63  64                        91  92   
+ 65  66  67  68  69  70  71    93  94  95  96  97  98  99   
+ 72  73  74  75  76  77  78   100 101 102 103 104 105 106   
+ 79  80  81  82  83  84  85   107 108 109 110 111 112 113   
+ 86  87  88  89  90           114 115 116 117 118 119 120   
+                                                            
+            May                           June           
+Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
+121 122 123 124 125 126 127               152 153 154 155   
+128 129 130 131 132 133 134   156 157 158 159 160 161 162   
+135 136 137 138 139 140 141   163 164 165 166 167 168 169   
+142 143 144 145 146 147 148   170 171 172 173 174 175 176   
+149 150 151                   177 178 179 180 181           
+                                                            
+            July                         August          
+Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
+                    182 183       213 214 215 216 217 218   
+184 185 186 187 188 189 190   219 220 221 222 223 224 225   
+191 192 193 194 195 196 197   226 227 228 229 230 231 232   
+198 199 200 201 202 203 204   233 234 235 236 237 238 239   
+205 206 207 208 209 210 211   240 241 242 243               
+212                                                         
+         September                      October          
+Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
+                244 245 246                           274   
+247 248 249 250 251 252 253   275 276 277 278 279 280 281   
+254 255 256 257 258 259 260   282 283 284 285 286 287 288   
+261 262 263 264 265 266 267   289 290 291 292 293 294 295   
+268 269 270 271 272 273       296 297 298 299 300 301 302   
+                              303 304                       
+          November                      December         
+Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
+        305 306 307 308 309                   335 336 337   
+310 311 312 313 314 315 316   338 339 340 341 342 343 344   
+317 318 319 320 321 322 323   345 346 347 348 349 350 351   
+324 325 326 327 328 329 330   352 353 354 355 356 357 358   
+331 332 333 334               359 360 361 362 363 364 365   
+                                                            
+
+Julian - Sunday-based year
diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear
new file mode 100755
index 0000000..8b8acd8
--- /dev/null
+++ b/tests/ts/cal/bigyear
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="Year 12345678901234567890"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+set -o pipefail
+
+USETERM=$( ts_has_option "useterm" "$*" )
+MYMONTH="12 12345678901234567890"
+MYYEAR="12345678901234567890"
+
+[ "$USETERM" == "yes" ] && TS_VERBOSE="yes"
+ts_log ""
+
+
+ts_log "Gregorian - Monday-based month"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1m
+fi
+$TS_CMD_CAL -1m $MYMONTH >> $TS_OUTPUT
+ts_log "Gregorian - Sunday-based month"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1s $MYMONTH
+fi
+$TS_CMD_CAL -1s $MYMONTH >> $TS_OUTPUT
+ts_log "Julian - Monday-based month"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1mj $MYMONTH
+fi
+$TS_CMD_CAL -1mj $MYMONTH >> $TS_OUTPUT
+ts_log "Julian - Sunday-based month"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1sj $MYMONTH
+fi
+$TS_CMD_CAL -1sj $MYMONTH >> $TS_OUTPUT
+
+
+ts_log "Gregorian - Monday-based three months"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -3m
+fi
+$TS_CMD_CAL -3m $MYMONTH >> $TS_OUTPUT
+ts_log "Gregorian - Sunday-based three months"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -3s $MYMONTH
+fi
+$TS_CMD_CAL -3s $MYMONTH >> $TS_OUTPUT
+ts_log "Julian - Monday-based three months"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -3mj $MYMONTH
+fi
+$TS_CMD_CAL -3mj $MYMONTH >> $TS_OUTPUT
+ts_log "Julian - Sunday-based three months"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -3sj $MYMONTH
+fi
+$TS_CMD_CAL -3sj $MYMONTH >> $TS_OUTPUT
+
+
+ts_log "Gregorian - Monday-based year"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1m $MYYEAR
+fi
+$TS_CMD_CAL -1m $MYYEAR >> $TS_OUTPUT
+ts_log "Gregorian - Sunday-based year"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1s $MYYEAR
+fi
+$TS_CMD_CAL -1s $MYYEAR >> $TS_OUTPUT
+ts_log "Julian - Monday-based year"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1mj $MYYEAR
+fi
+$TS_CMD_CAL -1mj $MYYEAR >> $TS_OUTPUT
+ts_log "Julian - Sunday-based year"
+if [ "$USETERM" == "yes" ]; then
+	$TS_CMD_CAL -1sj $MYYEAR
+fi
+
+ts_finalize
-- 
1.8.2.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] docs: cal: stop telling year 9999 is upper limit
  2013-05-26  9:14 [PATCH 0000] pull: cal the branch four Sami Kerola
                   ` (2 preceding siblings ...)
  2013-05-26  9:14 ` [PATCH 3/4] tests: check cal works when year is far in future Sami Kerola
@ 2013-05-26  9:14 ` Sami Kerola
  2013-05-26 18:23 ` [PATCH 0000] pull: cal the branch four Bernhard Voelker
  2013-05-28 13:50 ` Karel Zak
  5 siblings, 0 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-26  9:14 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/cal.1 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc-utils/cal.1 b/misc-utils/cal.1
index ec99d60..4e7570d 100644
--- a/misc-utils/cal.1
+++ b/misc-utils/cal.1
@@ -85,7 +85,7 @@ Display version information and exit.
 \fB\-h\fR, \fB\-\-help\fR
 Display help screen and exit.
 .SH PARAMETERS
-A single parameter specifies the year (1 - 9999) to be displayed; note the
+A single parameter specifies the year to be displayed; note the
 year must be fully specified:
 .B "cal 89"
 will not display a calendar for 1989.
-- 
1.8.2.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0000] pull: cal the branch four
  2013-05-26  9:14 [PATCH 0000] pull: cal the branch four Sami Kerola
                   ` (3 preceding siblings ...)
  2013-05-26  9:14 ` [PATCH 4/4] docs: cal: stop telling year 9999 is upper limit Sami Kerola
@ 2013-05-26 18:23 ` Bernhard Voelker
  2013-05-26 18:55   ` Sami Kerola
  2013-05-28 13:50 ` Karel Zak
  5 siblings, 1 reply; 11+ messages in thread
From: Bernhard Voelker @ 2013-05-26 18:23 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

Hi Sami,

On 05/26/2013 11:14 AM, Sami Kerola wrote:
> The cal branch I have in my git has got fixes to issues reviewed earlier,
> and I hope all works.  Based on that I decided to get rid of upper cal
> year limit, 9999, and replace it with unsigned long.  I know the change
> does not make much practical sense, the point of the change is that where
> there is no need to have artificial limits to a random magic number they
> should not exist.

unsigned years ... hmm, not that this would work today, but what about BC
years? E.g. on what weekday did Julius Caesar die (March 15th, 44 BC, [1])?
Maybe a future improvement (... having to make years signed again)?

[1] http://en.wikipedia.org/wiki/Julius_Caesar

Have a nice day,
Berny

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0000] pull: cal the branch four
  2013-05-26 18:23 ` [PATCH 0000] pull: cal the branch four Bernhard Voelker
@ 2013-05-26 18:55   ` Sami Kerola
  2013-05-26 19:59     ` Sami Kerola
  2013-05-28 13:49     ` Karel Zak
  0 siblings, 2 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-26 18:55 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: util-linux

On 26 May 2013 19:23, Bernhard Voelker <mail@bernhard-voelker.de> wrote:
> On 05/26/2013 11:14 AM, Sami Kerola wrote:
>> The cal branch I have in my git has got fixes to issues reviewed earlier,
>> and I hope all works.  Based on that I decided to get rid of upper cal
>> year limit, 9999, and replace it with unsigned long.  I know the change
>> does not make much practical sense, the point of the change is that where
>> there is no need to have artificial limits to a random magic number they
>> should not exist.
>
> unsigned years ... hmm, not that this would work today, but what about BC
> years? E.g. on what weekday did Julius Caesar die (March 15th, 44 BC, [1])?
> Maybe a future improvement (... having to make years signed again)?
>
> [1] http://en.wikipedia.org/wiki/Julius_Caesar

Hi Berny,

You are right. I'll make the year to be signed, and make error to be
displayed, for now, if negative year is defined.

BTW I tried the Tøndering's algorithm negative years and it gave odd
and obviously wrong results. If someone who is part of this list is
interested of mathematical puzzles making the negative year weekday
determination to work should be interesting challenge.

--
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0000] pull: cal the branch four
  2013-05-26 18:55   ` Sami Kerola
@ 2013-05-26 19:59     ` Sami Kerola
  2013-05-28 13:49     ` Karel Zak
  1 sibling, 0 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-26 19:59 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: util-linux

On 26 May 2013 19:55, Sami Kerola <kerolasa@iki.fi> wrote:
> On 26 May 2013 19:23, Bernhard Voelker <mail@bernhard-voelker.de> wrote:
>> On 05/26/2013 11:14 AM, Sami Kerola wrote:
>>> The cal branch I have in my git has got fixes to issues reviewed earlier,
>>> and I hope all works.  Based on that I decided to get rid of upper cal
>>> year limit, 9999, and replace it with unsigned long.  I know the change
>>> does not make much practical sense, the point of the change is that where
>>> there is no need to have artificial limits to a random magic number they
>>> should not exist.
>>
>> unsigned years ... hmm, not that this would work today, but what about BC
>> years? E.g. on what weekday did Julius Caesar die (March 15th, 44 BC, [1])?
>> Maybe a future improvement (... having to make years signed again)?
>>
>> [1] http://en.wikipedia.org/wiki/Julius_Caesar
>
> You are right. I'll make the year to be signed, and make error to be
> displayed, for now, if negative year is defined.

The year is now signed integer.

https://github.com/kerolasa/lelux-utiliteetit/commit/e44fe4712140774b677de466affc31e0581ee335

--
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0000] pull: cal the branch four
  2013-05-26 18:55   ` Sami Kerola
  2013-05-26 19:59     ` Sami Kerola
@ 2013-05-28 13:49     ` Karel Zak
  2013-05-29 16:20       ` Sami Kerola
  1 sibling, 1 reply; 11+ messages in thread
From: Karel Zak @ 2013-05-28 13:49 UTC (permalink / raw)
  To: kerolasa; +Cc: Bernhard Voelker, util-linux

On Sun, May 26, 2013 at 07:55:55PM +0100, Sami Kerola wrote:
> On 26 May 2013 19:23, Bernhard Voelker <mail@bernhard-voelker.de> wrote:
> > On 05/26/2013 11:14 AM, Sami Kerola wrote:
> >> The cal branch I have in my git has got fixes to issues reviewed earlier,
> >> and I hope all works.  Based on that I decided to get rid of upper cal
> >> year limit, 9999, and replace it with unsigned long.  I know the change
> >> does not make much practical sense, the point of the change is that where
> >> there is no need to have artificial limits to a random magic number they
> >> should not exist.
> >
> > unsigned years ... hmm, not that this would work today, but what about BC
> > years? E.g. on what weekday did Julius Caesar die (March 15th, 44 BC, [1])?
> > Maybe a future improvement (... having to make years signed again)?
> >
> > [1] http://en.wikipedia.org/wiki/Julius_Caesar
> 
> Hi Berny,
> 
> You are right. I'll make the year to be signed, and make error to be
> displayed, for now, if negative year is defined.
> 
> BTW I tried the Tøndering's algorithm negative years and it gave odd
> and obviously wrong results. If someone who is part of this list is
> interested of mathematical puzzles making the negative year weekday
> determination to work should be interesting challenge.

 If I good remember from "my previous life" than for example
 PostgreSQL uses Julian calendar for unlimited datetime calculations.

 See  https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/datetime.c

 and date2j(), j2date() and j2day() functions. Anyway, I have no clue
 if the calculations are correct (in regards to reformation 1752).

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0000] pull: cal the branch four
  2013-05-26  9:14 [PATCH 0000] pull: cal the branch four Sami Kerola
                   ` (4 preceding siblings ...)
  2013-05-26 18:23 ` [PATCH 0000] pull: cal the branch four Bernhard Voelker
@ 2013-05-28 13:50 ` Karel Zak
  5 siblings, 0 replies; 11+ messages in thread
From: Karel Zak @ 2013-05-28 13:50 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, May 26, 2013 at 10:14:06AM +0100, Sami Kerola wrote:
>  misc-utils/Makemodule.am   |   2 +-
>  misc-utils/cal.1           |  16 +-
>  misc-utils/cal.c           | 611 +++++++++++++++++++++++----------------------
>  tests/expected/cal/1m      |  48 ++--
>  tests/expected/cal/3m      |  48 ++--
>  tests/expected/cal/bigyear | 206 +++++++++++++++
>  tests/expected/cal/color   |  55 ++++
>  tests/expected/cal/sep1752 | 198 +++++++++++++++
>  tests/expected/cal/year    | 240 +++++++++---------
>  tests/ts/cal/bigyear       |  95 +++++++
>  tests/ts/cal/color         |  68 +++++
>  tests/ts/cal/sep1752       |  95 +++++++
>  12 files changed, 1211 insertions(+), 471 deletions(-)
>  create mode 100644 tests/expected/cal/bigyear
>  create mode 100644 tests/expected/cal/color
>  create mode 100644 tests/expected/cal/sep1752
>  create mode 100755 tests/ts/cal/bigyear
>  create mode 100755 tests/ts/cal/color
>  create mode 100755 tests/ts/cal/sep1752

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0000] pull: cal the branch four
  2013-05-28 13:49     ` Karel Zak
@ 2013-05-29 16:20       ` Sami Kerola
  0 siblings, 0 replies; 11+ messages in thread
From: Sami Kerola @ 2013-05-29 16:20 UTC (permalink / raw)
  To: Karel Zak; +Cc: Bernhard Voelker, util-linux

On 28 May 2013 14:49, Karel Zak <kzak@redhat.com> wrote:
>  If I good remember from "my previous life" than for example
>  PostgreSQL uses Julian calendar for unlimited datetime calculations.
>
>  See  https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/datetime.c
>
>  and date2j(), j2date() and j2day() functions. Anyway, I have no clue
>  if the calculations are correct (in regards to reformation 1752).

Inspiring.

Perhaps the easiest way to signed year to work is shift year zero to
(LONG_MAX / 2). After that the all left to do is to match the week day
vs year, month, day equation table with new alignment, and find how
1752 has alteration has to be done. While that's a bit of work I find
it much easier than fixing the divisions when negative numbers are
involved. (*ehm* not even amateur mathematician talking)

--
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-05-29 16:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-26  9:14 [PATCH 0000] pull: cal the branch four Sami Kerola
2013-05-26  9:14 ` [PATCH 1/4] cal: use Claus Tøndering's day of the week algorithm Sami Kerola
2013-05-26  9:14 ` [PATCH 2/4] cal: remove arbitrary limit of maxium year being 9999 Sami Kerola
2013-05-26  9:14 ` [PATCH 3/4] tests: check cal works when year is far in future Sami Kerola
2013-05-26  9:14 ` [PATCH 4/4] docs: cal: stop telling year 9999 is upper limit Sami Kerola
2013-05-26 18:23 ` [PATCH 0000] pull: cal the branch four Bernhard Voelker
2013-05-26 18:55   ` Sami Kerola
2013-05-26 19:59     ` Sami Kerola
2013-05-28 13:49     ` Karel Zak
2013-05-29 16:20       ` Sami Kerola
2013-05-28 13:50 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox