Skip to content

Commit

Permalink
added units of day, week, minute [thanks to Andre Sa]
Browse files Browse the repository at this point in the history
  • Loading branch information
iraikov committed Aug 8, 2020
1 parent e5fe1b8 commit aa75ec7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ Defines a variable whose name is the concatenated `PREFIX` and `UNIT` and that h
<tr><th>Name</th><th>Quantity</th><th>Factor</th><th>Abbreviation(s)</th></tr>
<tr><td>second</td><td>Time</td><td>1.0</td><td>(s seconds)</td></tr>
<tr><td>hour</td><td>Time</td><td>(* sixty (* sixty second))</td><td>(h hrs hours)</td></tr>
<tr><td>minute</td><td>Time</td><td>(* sixty second)</td><td>(minutes)</td></tr>
<tr><td>day</td><td>Time</td><td>(* 24 hour)</td><td>(days)</td></tr>
<tr><td>week</td><td>Time</td><td>(* 7 day)</td><td>(weeks)</td></tr>
</table>

### Units of Acceleration
Expand Down Expand Up @@ -457,7 +460,7 @@ The following operations are available for operations on quantities with units:

## Version history


- 3.3 : Additional units of time [Andre Sa]
- 3.0 : Compatibility with CHICKEN 5
- 2.6 : Bugfixes in unit* and unit/
- 2.3 : Added definitions for centimeter and centimeter-squared
Expand All @@ -478,7 +481,7 @@ The following operations are available for operations on quantities with units:
## License

>
> Copyright 2007-2018 Ivan Raikov.
> Copyright 2007-2020 Ivan Raikov.
>
> This program is free software: you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
Expand Down
3 changes: 3 additions & 0 deletions test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
(print Frequency)
(print (unit* millisecond hertz))
(print (quantity-int (unit-dims (unit* millisecond hertz))))

(print (unit-convert week second))

11 changes: 9 additions & 2 deletions unitconv.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;;
;; TODO: implement non-strict conversion (e.g. mass <-> energy, mass <-> weight)
;;
;; Copyright 2007-2018 Ivan Raikov.
;; Copyright 2007-2020 Ivan Raikov.
;;
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -176,6 +176,9 @@
;; Units of time
second s seconds
hour h hrs hours
minute minutes
day days
week weeks

;; Units of acceleration
meters-per-second-squared m/s2 m/s^2 m/sec2 m/sec^2
Expand Down Expand Up @@ -843,8 +846,12 @@
(define-unit atomic-mass-unit Mass 1.6605402e-27 amu atomic-mass-units)

;; Units of time
(define-unit second Time 1.0 s seconds)
(define-unit second Time 1.0 s seconds)
(define-unit hour Time (* sixty (* sixty second)) h hrs hours)
(define-unit minute Time (* sixty second) minutes)
(define-unit hour Time (* sixty minute) h hrs hours)
(define-unit day Time (* 24 hour) days)
(define-unit week Time (* 7 day) weeks)

;; Units of acceleration
(define-unit meters-per-second-squared Acceleration (/ meter (* second second)) m/s2 m/s^2 m/sec2 m/sec^2)
Expand Down

0 comments on commit aa75ec7

Please sign in to comment.