summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-05-15 18:35:36 (GMT)
committersebres <sebres@users.sourceforge.net>2017-05-15 18:35:36 (GMT)
commit072ced07bed0a287c473e942e7249ec197709cda (patch)
tree485046a620e9526e9f10aa31a8acad6cb6edf7d2 /generic
parent176f58d94fc581670638cccd451aab3bc9572e99 (diff)
parent9f5e6e9b5ff1c04538705d20e601b16c4df821e5 (diff)
downloadtcl-072ced07bed0a287c473e942e7249ec197709cda.zip
tcl-072ced07bed0a287c473e942e7249ec197709cda.tar.gz
tcl-072ced07bed0a287c473e942e7249ec197709cda.tar.bz2
merge sebres-8-6-clock-speedup
Diffstat (limited to 'generic')
-rw-r--r--generic/tclClockFmt.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c
index 70b3ad7..d3cb339 100644
--- a/generic/tclClockFmt.c
+++ b/generic/tclClockFmt.c
@@ -2489,13 +2489,13 @@ ClockFmtToken_StarDate_Proc(
{
int fractYear;
/* Get day of year, zero based */
- int doy = dateFmt->date.dayOfYear - 1;
+ int v = dateFmt->date.dayOfYear - 1;
/* Convert day of year to a fractional year */
if (IsGregorianLeapYear(&dateFmt->date)) {
- fractYear = 1000 * doy / 366;
+ fractYear = 1000 * v / 366;
} else {
- fractYear = 1000 * doy / 365;
+ fractYear = 1000 * v / 365;
}
/* Put together the StarDate as "Stardate %02d%03d.%1d" */
@@ -2507,8 +2507,10 @@ ClockFmtToken_StarDate_Proc(
dateFmt->output = _itoaw(dateFmt->output,
fractYear, '0', 3);
*dateFmt->output++ = '.';
- dateFmt->output = _itoaw(dateFmt->output,
- dateFmt->date.localSeconds % SECONDS_PER_DAY / ( SECONDS_PER_DAY / 10 ), '0', 1);
+ /* be sure positive after decimal point (note: clock-value can be negative) */
+ v = dateFmt->date.localSeconds % SECONDS_PER_DAY / ( SECONDS_PER_DAY / 10 );
+ if (v < 0) v = 10 + v;
+ dateFmt->output = _itoaw(dateFmt->output, v, '0', 1);
return TCL_OK;
}