YuHeng (玉衡)

A local nutrition tracking app powered by AI

View the Project on GitHub formaxcn/yuheng

Unit Preferences & Conversion

YuHeng provides a robust system for handling different nutritional and weight units, allowing users to track their intake in the units they are most comfortable with.

Supported Units

Energy

Weight

Implementation Details

The core conversion logic is centralized in lib/units.ts.

Base Units

Internally, YuHeng stores all data in base units:

Conversions only happen during input (when saving to the database) and output (when displaying to the user).

Formatting Helpers

The system provides several helper functions for clean UI rendering:

User Configuration

Users can switch their preferred units in the Settings page. Changing these settings only affects how data is displayed; existing logs in the database remain consistent because they are stored in base units.