From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Simon Pugnet Newsgroups: gmane.emacs.help Subject: Using Calc unit conversion functions in an Org Spreadsheet Date: Wed, 15 Nov 2023 10:52:37 +0000 Message-ID: <87msvfp9p1.fsf@polaris64.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2741"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 15 16:19:49 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3HgC-0000V5-Oq for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 15 Nov 2023 16:19:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3Hfj-0002QE-D0; Wed, 15 Nov 2023 10:19:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3DYq-00070z-Eu for help-gnu-emacs@gnu.org; Wed, 15 Nov 2023 05:55:56 -0500 Original-Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1r3DYo-00044C-IT for help-gnu-emacs@gnu.org; Wed, 15 Nov 2023 05:55:56 -0500 Original-Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4SVg7J16khz9t4N for ; Wed, 15 Nov 2023 11:55:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polaris64.net; s=MBO0001; t=1700045740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=WSQvXKaKT3YMAiqpKMjfWiH5LUg29Z4OXvYVLXWsznc=; b=XyAJxeUv7uZVX5SNN5O6/KBkFTgdQ6P0tWjeHLdOYTCfdpdjZ4CHtW63Ru5wlHS0E6d4Q9 x/QXzX3hynVNdiy+FsujCk3qc3PDmNb6S6hc/dv/nwqXLNWIaKRME0ezM2byNGOOLC5jmJ HTGqqxoNTyyhWNGHy8WH4i6eNX+Wsj8TfNbPJlyIZwA16qCRAlU9m3oIMSGA9zsZyw54Pk nbbU8UHAx21N+OPo2k7r2SMKeuWVN0NdLKl7qJAB2qLgNN/zecoXHcvAr6FS0agrq2k7cy CvaoXJaF8/hLaDnzNP6x/YUAjdL7VDsae0BshaOF8vEyV3CvwD3D0GQ8oi2giQ== X-Rspamd-Queue-Id: 4SVg7J16khz9t4N Received-SPF: pass client-ip=2001:67c:2050:0:465::202; envelope-from=simon@polaris64.net; helo=mout-p-202.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, LOTS_OF_MONEY=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 15 Nov 2023 10:19:18 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145536 Archived-At: --=-=-= Content-Type: text/plain; format=flowed Hi everyone, I'm currently trying to use Org mode's spreadsheet functionality to calculate quotes for clients. For example, I might have a table like this: - | Task | Time estimate | Rounded hours | CPH | Cost | |---------+---------------+---------------+-------------+---------------| | Task #1 | 1 hr + 35 min | 1.75 hr | 50 GBP / hr | 87.5 GBP | | Task #2 | 0 hr + 20 min | 20 min | 50 GBP / hr | 16.666667 GBP | #+TBLFM: $3=usimplify(ceil($2*4)/4)::$5=usimplify($4*$3) What I'm trying to do here is to round the time estimate to the nearest 15 minutes, then multiply that figure by the cost per hour (CPH) to produce the final cost. The problem with the example above is with the ~usimplify~ calls. In the first case, the units get simplified to hours (1.75 hr) and in the second it gets simplified to minutes (20 min). The rounding calculation (ceil(x * 4) / 4) therefore only works when the units are hours as the minutes have no need of rounding. You can see that above: 1 hr + 35 min gets rounded correctly to 1.75 hr, but 0 hr + 20 min does not (it becomes 20 min, but should be 30 min). I'm therefore trying to replace ~usimplify~ with a function which converts units, i.e. to force the value to be in hours. However I can't find such a function. I found ~math-convert-units~ which seems to do exactly what I need however I can't get it to work and it's not documented. Passing a string expression such as ~(math-convert-units "45 min" 'hr)~ causes the error "Lisp error: (wrong-type-argument number-or-marker-p hr)". Any help would be greatly appreciated! Kind regards, -- Simon Pugnet https://www.polaris64.net/ PGP key fingerprint: 3BF7 85DE 162C 00C8 FB4D A6FD BA13 59A8 2C0B 3EF9 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCAAyFiEEO/eF3hYsAMj7Tab9uhNZqCwLPvkFAmVUo6oUHHNpbW9uQHBv bGFyaXM2NC5uZXQACgkQuhNZqCwLPvlQfg//TcresRx20VAi/5v9JNNHrk12czF5 /8YK/KjXFF3ixtFWMS97riKL1wSEJogQMpy1Z0nSWO1HzlgNGl0LORmI3WPPF458 VRGetn2ZoSPflBrD05DFKTLIOY87hXdHKvELglkY+ylLH0JqkfH9catDqtrlYIdy 6SoIYKPcVZmOhDWvJdKd/9xvNg6np3nHAXGo7g04YgYlcL3psc3WrFLl1yCAMj8M hSzeJ9gtUxpIdhjbrQr+0HFQkS/jLciQ2cPSrYQQtBQMW0mB69E0lmqy5kI5Bq/j FhRO8UoEaCPeAzOvUu4rMx6uCcC5uy4fo0CSlbWnTGXv5OvnOitvHYKrxylZtcQT 5w2nacmz3+YdZHooO92oA1JEGOhuIuETfuZlpzf5nnGhjZUl7ZsD9BJdCwwNODX5 cWbl7e8Mq09JFfiFGF13e+VhyXzO8jBplcM94YYGy12Lf+98jrRLkWtay3OBBaIA sB+Ti/gV5wxsrsQ1BCMlgfz8xO21bILYT1VW8hXklrz51VClNqMzdmHu+IBSoMKK P8fui4wcPD0V1NKfEHcCJFA8XuULs1jC3aOQzXNjUcqMntQ5ETTECiCiwb8rsuy1 gs9CoUIjQV9k3j+5wVxfJcCOS3nqnvspp/yojxCBpNyGvFtslrWtsne6+ZJA/GNg c9iqjowqDAz5nok= =tBIc -----END PGP SIGNATURE----- --=-=-=--