A new class modeling temperature (Kelvin, Celsius, Fahrenheit, etc.) would be useful.

Comments

r0nn1ef created an issue. See original summary.

r0nn1ef’s picture

Status: Active » Needs review
StatusFileSize
new8.12 KB

Here's a patch that adds the temperature measurement and tests. It supports the three most common units; Kelvin, Fahrenheit, and Celsius.

bojanz’s picture

Status: Needs review » Needs work
Issue tags: -feature request

This patch doesn't completely follow coding standards.
You can install phpcs and run "phpcs --standard=phpcs.xml" from the module folder to get the list of warnings. Some of them include no newline at the end of files (also shown in the patch), others are about the placement of "else" (should be below the closing brace, not on it), etc.

Also, could you tell me what the primary use case will be for this feature?

dhruveshdtripathi’s picture

Status: Needs work » Needs review
StatusFileSize
new8.06 KB
new2.88 KB

Changes made according to comment #3. Interdiff added.

Thank you.

r0nn1ef’s picture

The feature is needed in a SCUBA dive log module suite that I'm writing. All dive log software allows users to select between Fahrenheit and Celsius, but to be complete, I added Kelvin in since it is the other widely-used temperature scale. There were others, but they haven't been used in over 100 years.

bojanz’s picture

Status: Needs review » Needs work

The patch still doesn't pass phpcs. There are spaces around functional calls and other non-Drupal style decisions.

The unit constants need to be machine readable, they should not have the degree symbol.

  • bojanz committed f579fb0 on 8.x-1.x authored by r0nn1ef
    Issue #2877706 by dhruveshdtripathi, r0nn1ef, bojanz: Temperature...
bojanz’s picture

Status: Needs work » Fixed

Cleaned up and committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.