NAME

App::VitaminUtils - Utilities related to vitamins

VERSION

This document describes version 0.007 of App::VitaminUtils (from Perl distribution App-VitaminUtils), released on 2024-07-06.

DESCRIPTION

This distributions provides the following command-line utilities:

1. convert-choline-unit
2. convert-cobalamin-unit
3. convert-pantothenic-acid-unit
4. convert-pyridoxine-unit
5. convert-vitamin-a-unit
6. convert-vitamin-b12-unit
7. convert-vitamin-b5-unit
8. convert-vitamin-b6-unit
9. convert-vitamin-d-unit
10. convert-vitamin-e-unit

FUNCTIONS

convert_choline_unit

Usage:

convert_choline_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert a choline quantity from one unit to another.

Examples:

  • Show all possible conversions:

    convert_choline_unit();

    Result:

    [
      200,
      "OK",
      [
        { amount => 0.001, unit => "mg" },
        { amount => 1, unit => "mcg" },
        { amount => 1, unit => "mcg-choline" },
        { amount => 2.43112220408947, unit => "mcg-choline-bitartrate" },
      ],
      {},
    ]

If target unit is not specified, will show all known conversions.

This function is not exported.

Arguments ('*' denotes required arguments):

  • quantity => str (default: "1 mcg")

    (No description)

  • to_unit => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

convert_vitamin_a_unit

Usage:

convert_vitamin_a_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert a vitamin A quantity from one unit to another.

Examples:

  • Show all possible conversions:

    convert_vitamin_a_unit();

    Result:

    [
      200,
      "OK",
      [
        { amount => 0.001, unit => "mg" },
        { amount => 1, unit => "mcg" },
        { amount => 1, unit => "mcg-all-trans-retinol" },
        {
          amount => 12.000000048,
          unit   => "mcg-dietary-all-trans-beta-carotene",
        },
        { amount => 23.999999808, unit => "mcg-alpha-carotene" },
        { amount => 23.999999808, unit => "mcg-beta-cryptoxanthin" },
        {
          amount => 2,
          unit   => "mcg-all-trans-beta-carotene-as-food-supplement",
        },
        { amount => 1.14655200007338, unit => "mcg-all-trans-retinyl-acetate" },
        {
          amount => 1.83333333333333,
          unit   => "mcg-all-trans-retinyl-palmitate",
        },
        {
          amount => 1.19666666666667,
          unit   => "mcg-all-trans-retinyl-propionate",
        },
        { amount => 3.33333333333333, unit => "IU" },
        { amount => 3.33333333333333, unit => "IU-retinol" },
        { amount => 1.66666666666667, unit => "IU-beta-carotene" },
      ],
      {},
    ]
  • Convert from mcg to IU (retinol):

    convert_vitamin_a_unit(quantity => "1500 mcg", to_unit => "IU"); # -> [200, "OK", 5000, {}]
  • Convert from mcg to IU (retinol):

    convert_vitamin_a_unit(quantity => "1500 mcg", to_unit => "IU-retinol"); # -> [200, "OK", 5000, {}]
  • Convert from mcg to IU (beta-carotene):

    convert_vitamin_a_unit(quantity => "1500 mcg", to_unit => "IU-beta-carotene"); # -> [200, "OK", 2500, {}]
  • Convert from IU to mg:

    convert_vitamin_a_unit(quantity => "5000 IU", to_unit => "mg"); # -> [200, "OK", 1.5, {}]

If target unit is not specified, will show all known conversions.

This function is not exported.

Arguments ('*' denotes required arguments):

  • quantity => str (default: "1 mcg")

    (No description)

  • to_unit => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

convert_vitamin_b12_unit

Usage:

convert_vitamin_b12_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert a vitamin B12 (cobalamin) quantity from one unit to another.

Examples:

  • Show all possible conversions:

    convert_vitamin_b12_unit();

    Result:

    [
      200,
      "OK",
      [
        { amount => 0.001, unit => "mg" },
        { amount => 1, unit => "mcg" },
        { amount => 1, unit => "mcg-cobalamin" },
        { amount => 0.00100001106712952, unit => "mcg-cyanocobalamin" },
      ],
      {},
    ]

If target unit is not specified, will show all known conversions.

This function is not exported.

Arguments ('*' denotes required arguments):

  • quantity => str (default: "1 mcg")

    (No description)

  • to_unit => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

convert_vitamin_b5_unit

Usage:

convert_vitamin_b5_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert a vitamin B5 (pantothenic acid) quantity from one unit to another.

Examples:

  • Show all possible conversions:

    convert_vitamin_b5_unit();

    Result:

    [
      200,
      "OK",
      [
        { amount => 1, unit => "mg" },
        { amount => 1, unit => "mg-pantothenic-acid" },
        { amount => 1.09170305676856, unit => "mg-d-calcium-pantothenate" },
      ],
      {},
    ]

If target unit is not specified, will show all known conversions.

This function is not exported.

Arguments ('*' denotes required arguments):

  • quantity => str (default: "1 mg")

    (No description)

  • to_unit => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

convert_vitamin_b6_unit

Usage:

convert_vitamin_b6_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert a vitamin B6 (pyridoxine) quantity from one unit to another.

Examples:

  • Show all possible conversions:

    convert_vitamin_b6_unit();

    Result:

    [
      200,
      "OK",
      [
        { amount => 1, unit => "mg" },
        { amount => 1, unit => "mg-pyridoxine" },
        { amount => 1.21550990640574, unit => "mg-pyridoxine-hydrochloride" },
      ],
      {},
    ]

If target unit is not specified, will show all known conversions.

This function is not exported.

Arguments ('*' denotes required arguments):

  • quantity => str (default: "1 mg")

    (No description)

  • to_unit => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

convert_vitamin_d_unit

Usage:

convert_vitamin_d_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert a vitamin D quantity from one unit to another.

Examples:

  • Show all possible conversions:

    convert_vitamin_d_unit();

    Result:

    [
      200,
      "OK",
      [
        { amount => 1, unit => "mcg" },
        { amount => 0.001, unit => "mg" },
        { amount => 40, unit => "IU" },
      ],
      {},
    ]
  • Convert from mcg to IU:

    convert_vitamin_d_unit(quantity => "2 mcg", to_unit => "IU"); # -> [200, "OK", 80, {}]
  • Convert from IU to mg:

    convert_vitamin_d_unit(quantity => "5000 IU", to_unit => "mg"); # -> [200, "OK", 0.125, {}]

If target unit is not specified, will show all known conversions.

This function is not exported.

Arguments ('*' denotes required arguments):

  • quantity => str (default: "1 mcg")

    (No description)

  • to_unit => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

convert_vitamin_e_unit

Usage:

convert_vitamin_e_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert a vitamin E quantity from one unit to another.

Examples:

  • Show all possible conversions:

    convert_vitamin_e_unit();

    Result:

    [
      200,
      "OK",
      [
        { amount => 1, unit => "mg" },
        { amount => 1000, unit => "mcg" },
        { amount => 1, unit => "mg-alpha-TE" },
        { amount => 1, unit => "mg-alpha-tocopherol-equivalent" },
        { amount => 1, unit => "mg-rrr-alpha-tocopherol" },
        { amount => 1, unit => "mg-d-alpha-tocopherol" },
        { amount => 1.09558823529412, unit => "mg-d-alpha-tocopheryl-acetate" },
        { amount => 1.49, unit => "mg-dl-alpha-tocopheryl-acetate" },
        { amount => 1.35454545454545, unit => "mg-dl-alpha-tocopherol" },
        { amount => 2, unit => "mg-beta-tocopherol" },
        { amount => 10, unit => "mg-gamma-tocopherol" },
        { amount => 3.33333333333333, unit => "mg-alpha-tocotrienol" },
        { amount => 1.49253731343284, unit => "IU" },
        { amount => 1.49253731343284, unit => "IU-natural" },
        { amount => 1.11111111111111, unit => "IU-synthetic" },
      ],
      {},
    ]
  • Convert from mg to IU (d-alpha-tocopherol/natural vitamin E):

    convert_vitamin_e_unit(quantity => "67 mg", to_unit => "IU"); # -> [200, "OK", 100, {}]
  • Convert from mg to IU (d-alpha-tocopherol/natural vitamin E):

    convert_vitamin_e_unit(quantity => "67 mg", to_unit => "IU-natural"); # -> [200, "OK", 100, {}]
  • Convert from mg to IU (dl-alpha-tocopherol/synthetic vitamin E):

    convert_vitamin_e_unit(quantity => "90 mg", to_unit => "IU-synthetic"); # -> [200, "OK", 100, {}]
  • Convert from IU to mg:

    convert_vitamin_e_unit(quantity => "400 IU", to_unit => "mg"); # -> [200, "OK", 268, {}]

If target unit is not specified, will show all known conversions.

This function is not exported.

Arguments ('*' denotes required arguments):

  • quantity => str (default: "1 mg")

    (No description)

  • to_unit => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-VitaminUtils.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-VitaminUtils.

SEE ALSO

App::MineralUtils

Physics::Unit

Online vitamin converters: https://www.rfaregulatoryaffairs.com/vitamin-converter, https://avsnutrition.com.au/wp-content/themes/avs-nutrition/vitamin-converter.html.

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2024, 2022, 2021, 2020 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-VitaminUtils

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.