Skip to content

Commit e323fb1

Browse files
Merge pull request #14 from rustprooflabs/add-temp-conversions
Add C to F and F to C conversions
2 parents 379e5f9 + 9510531 commit e323fb1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ fn area_acre_to_km2(acres: f64) -> f64 {
160160

161161

162162

163+
/////////////////////////////
164+
// Temperature conversions
165+
#[pg_extern(immutable)]
166+
fn temp_c_to_f(celsius: f64) -> f64 {
167+
(celsius * 9. / 5.) + 32.
168+
}
169+
170+
#[pg_extern(immutable)]
171+
fn temp_f_to_c(fahrenheit: f64) -> f64 {
172+
(fahrenheit - 32.) / 1.8
173+
}
174+
175+
163176
/////////////////////////////
164177
// Add comments to functions
165178
extension_sql_file!("sql/comments.sql",

0 commit comments

Comments
 (0)