[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e368697 1/2: Fix description of Unix time, mention
From: |
Jay Belanger |
Subject: |
[Emacs-diffs] master e368697 1/2: Fix description of Unix time, mention new function. |
Date: |
Fri, 10 Apr 2015 01:06:56 +0000 |
branch: master
commit e368697ce3647f1f34f4777d553604866c56ad25
Author: Jay Belanger <address@hidden>
Commit: Jay Belanger <address@hidden>
Fix description of Unix time, mention new function.
* lisp/calc/calc-forms.el (calcFunc-unixtime): Fix adjustment for
Unix time.
* doc/misc/calc.texi (Date Forms): Fix description of Unix time.
(Basic Operations on Units): Mention `calc-convert-exact-units'.
---
doc/misc/calc.texi | 34 ++++++++++++++--------------------
lisp/calc/calc-forms.el | 4 ++--
2 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi
index 78af706..74fb50f 100644
--- a/doc/misc/calc.texi
+++ b/doc/misc/calc.texi
@@ -11098,12 +11098,12 @@ noon address@hidden) Julian day numbering is largely
used in astronomy.
@cindex Unix time format
The Unix operating system measures time as an integer number of
seconds since midnight, Jan 1, 1970. To convert a Calc date
-value into a Unix time stamp, first subtract 719164 (the code
+value into a Unix time stamp, first subtract 719163 (the code
for @samp{<Jan 1, 1970>}), then multiply by 86400 (the number of
seconds in a day) and press @kbd{R} to round to the nearest
integer. If you have a date form, you can simply subtract the
day @samp{<Jan 1, 1970>} instead of unpacking and subtracting
-719164. Likewise, divide by 86400 and add @samp{<Jan 1, 1970>}
+719163. Likewise, divide by 86400 and add @samp{<Jan 1, 1970>}
to convert from Unix time to a Calc date form. (Note that
Unix normally maintains the time in the GMT time zone; you may
need to subtract five hours to get New York time, or eight hours
@@ -27860,14 +27860,20 @@ while typing @kbd{u c au/yr @key{RET}} produces
If the units you request are inconsistent with the original units, the
number will be converted into your units times whatever ``remainder''
-units are left over. (This can be disabled; @pxref{Customizing Calc}.)
-For example, converting @samp{55 mph} into acres
-produces @samp{6.08e-3 acre / m s}. (Recall that multiplication binds
-more strongly than division in Calc formulas, so the units here are
-acres per meter-second.) Remainder units are expressed in terms of
+units are left over. For example, converting @samp{55 mph} into acres
+produces @samp{6.08e-3 acre / (m s)}. Remainder units are expressed in terms of
``fundamental'' units like @samp{m} and @samp{s}, regardless of the
input units.
address@hidden u n
address@hidden calc-convert-exact-units
+If you intend that your new units be consistent with the original
+units, the @kbd{u n} (@code{calc-convert-exact-units}) command will
+check the units before the conversion. For example, to change
address@hidden/hr} to @samp{km/hr}, you could type @kbd{u c km @key{RET}},
+but @kbd{u n km @key{RET}} would signal an error.
+You would need to type @kbd{u n km/hr @key{RET}}.
+
One special exception is that if you specify a single unit name, and
a compatible unit appears somewhere in the units expression, then
that compatible unit will be converted to the new unit and the
@@ -35684,19 +35690,6 @@ as @samp{a/(b*c)}. If
@code{calc-multiplication-has-precedence} is
of @code{calc-multiplication-has-precedence} is @code{t}.
@end defvar
address@hidden calc-ensure-consistent-units
-When converting units, the variable @code{calc-ensure-consistent-units}
-determines whether or not the target units need to be consistent with the
-original units. If @code{calc-ensure-consistent-units} is @code{nil}, then
-the target units don't need to have the same dimensions as the original units;
-for example, converting @samp{100 ft/s} to @samp{m} will produce @samp{30.48
m/s}.
-If @code{calc-ensure-consistent-units} is address@hidden, then the target units
-need to have the same dimensions as the original units; for example, converting
address@hidden ft/s} to @samp{m} will result in an error, since @samp{ft/s} and
@samp{m}
-have different dimensions. The default value of
@code{calc-ensure-consistent-units}
-is @code{nil}.
address@hidden defvar
-
@defvar calc-context-sensitive-enter
The commands @code{calc-enter} and @code{calc-pop} will typically
duplicate the top of the stack. If
@@ -36497,6 +36490,7 @@ keystrokes are not listed in this summary.
@r{ defn@: u d @:unit, descr @: @:calc-define-unit@:}
@r{ @: u e @: @: @:calc-explain-units@:}
@r{ @: u g @:unit @: @:calc-get-unit-definition@:}
address@hidden @: u n @:units @: 18
@:calc-convert-exact-units@:}
@r{ @: u p @: @: @:calc-permanent-units@:}
@r{ a@: u r @: @: @:calc-remove-units@:}
@r{ a@: u s @: @: @:usimplify@:(a)}
diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el
index ca6d021..c6e1fdb 100644
--- a/lisp/calc/calc-forms.el
+++ b/lisp/calc/calc-forms.el
@@ -1438,11 +1438,11 @@ as measured in the integer number of days before
December 31, 1 BC (Gregorian)."
(defun calcFunc-unixtime (date &optional zone)
(if (math-realp date)
(progn
- (setq date (math-add 719164 (math-div date '(float 864 2))))
+ (setq date (math-add 719163 (math-div date '(float 864 2))))
(list 'date (math-sub date (math-div (calcFunc-tzone zone date)
'(float 864 2)))))
(if (eq (car date) 'date)
- (math-add (nth 1 (math-date-parts (nth 1 date) 719164))
+ (math-add (nth 1 (math-date-parts (nth 1 date) 719163))
(calcFunc-tzone zone date))
(math-reject-arg date 'datep))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master e368697 1/2: Fix description of Unix time, mention new function.,
Jay Belanger <=