Repository navigation
Add Time Format Support to decodeTime Function
Description:
This pull request introduces enhancements to the decodeTime function in the mapstructure package. The primary objective is to enable the function to handle time values with dynamic formats, providing more flexibility in decoding time representations.
Changes Made:
- Modified the
decodeTimefunction to support dynamic time formats. - Updated the test cases in
mapstructure_test.goto cover various scenarios, including decodingtime.Time,*time.Time, nil*time.Time, and a string representation of time with a dynamic format.
Code Modifications:
- Adjustments made to
decodeTimefunction inmapstructure.goto handle dynamic time formats. - Addition of a new test case in
mapstructure_test.goto cover the scenario of decoding a string representation of time with a dynamic format.
Test Cases Added:
- Decode string time:
- Purpose: To ensure that the
decodeTimefunction correctly decodes a string representation of time with a dynamic format. - Input:
"2023-11-30T12:34:56Z"(format: RFC3339, but can be any valid format) - Expected Output: No error, and the time value is correctly set in the output.
- Purpose: To ensure that the
Testing Approach:
- Run existing test cases to ensure that the original functionality remains intact.
- Execute the new test case to verify the added support for dynamic time formats.
- Manually review the modified code to ensure clarity and adherence to coding standards.
- Conduct additional testing with various time formats to validate the flexibility of the updated
decodeTimefunction.