ericberman / MyFlightbookWeb

The website and service for MyFlightbook
49 stars 18 forks source link

specify decimal vs. hh:mm tach/hobbs #1333

Closed ericberman closed 6 days ago

ericberman commented 2 weeks ago

Probably the simplest thing to do this is to base it off of private notes: #TACH:H#" would put the tach in hh:mm for that aircraft, "#HOBBS:H#" would put the hobbs in hh:mm for that aircraft. Would want to do this for iOS/Android too.

Or, if that gets too complicated (since it means changing things when the aircraft selected for a flight changes), just make it a global setting (on iOS/Android as well) and go with it. Less precise, but vastly simpler to manage.

ericberman commented 6 days ago

Wow, this gets complicated fast.

I have four kinds of numerical values in the system. Integers (whole numbers), times (an hour and a half of PIC time, for example), decimals (fuel added, say), and currency (monetary amounts). These are all stored under the covers as either whole numbers (for integers) or decimals (everything else), but the three non-integer values are formatted differently:

HH:MM is a personal or cultural preference (in the US we tend to use decimal, in Europe HH:MM is common), but it is just a format.

But Tach and hobbs are different because a given aircraft's meter will be in a static format, usually decimal (because most aircraft and aircraft parts are US-made, perhaps?) And presumably, you want to be able to enter these values by reading the instrument, even if its format doesn't match your preference. For this reason, these values are tagged as being decimals, not times.

Here’s what’s hard: I was going to have you put #TACH:H# and/or #HOBBS:H# into the private notes for any aircraft that uses hh:mm for tach or hobbs, respectively. That’s easy. But now I need to figure that out when I render the flight editing page what the aircraft’s preference is (also easy), and pass that deep into the bowels of the flight editing screen to the edit box so that it knows to be decimal or hh:mm. So far so good. But now if you change the aircraft, I have to re-render the base level of the page to recapture all of that information and pass it down to the various page components so that it all renders correctly. That actually requires a bunch of changes to the architecture, which isn’t rocket science but is something I’m loathe to do, both for fragility, maintainability, and performance. (I do change your property set with every change of aircraft because different aircraft can have different templates, or need specific properties – e.g., sims always pull in the “Simulator/Training Device Identifier” property and anonymous aircraft always pull in “Aircraft Registration”. But updating your property list is a partial page update, and won’t update hobbs or tach if those are in the flight times section).

And then there’s the complexity of display: do I mix and match, so that adjacent flights in the list of flights where one uses HHMM and the other uses decimal switch between them, so that one says “Tach: 413.2 – 415.1 (1.9)” and the other one says “413:12 – 415:06 (1:54)”, which can be confusing eyeballing these.

So I’m thinking the most elegant thing is to focus on making data entry easier. I currently enforce data formats for numbers that are either decimals (using your locale’s preferred decimal point – e.g., a period here in the US, a comma in France) or hh:mm, per your preference. But they’re either/or: if you’re using hh:mm, then you can’t use a decimal point, and if you’re using decimal, you can’t use the colon.

I can actually enforce that you adhere to one or the other input format simultaneously, though – i.e., I can enforce that you use a decimal point OR a colon, but not both.

Specifically, a numeric field must begin with zero or more digits, followed by EITHER a decimal point and more digits, OR by a colon and two digits (with the first of those two being limited to 0-5) OR by nothing. So "" (empty), "12" (twelve), ":12" (twelve minutes), ".2" (2 tenths of an hour, aka 12 minutes), "1.2", and "1:12" are all valid inputs, but "1.2:3" or "1:2" are not.

This means that on the web, I can just let you type any time value in either format it and I’ll understand it. But when I display the value, I’ll use your preferred mode (if it’s a time), or decimal (tach and hobbs).

I.e., if you: • Are using HH:MM and enter the PIC as 1.4 (or 1,4 in France), that’s fine but then it will subsequently display as 1:24. • If you are using decimal and enter the PIC as 1:24, it will then display as 1.4. • If you enter the tach or hobbs as 413.2, it will display as 413.2 • If you enter the tach or hobbs as 413:12, it will display as 413.2.

This is only on the web. On iOS or Android, I need to pick a keyboard, and there is no keyboard that is optimized for numeric with a colon. Time fields get a text keyboard when using hh:mm and a numeric keyboard when using decimal. Decimal fields are always numeric, so these fields will continue to get a decimal keyboard.