Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Asset Module Update to use gmt (versus tz) everywhere to avoid time/calculation issues #32308

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

josett225
Copy link
Contributor

FIX Asset Module issue as already discussed longely in this closed PR:
#31434

card.php and /class/assetdepreciationoptions.class.php

This fix is to avoid issue when using asset starting date that equal to either first or last day of fiscal year.

The solution is to get all the asset module using GMT (versus TZ) everywhere to avoid creating a new function to reset time as the following:
/**

  • Function to reset the time of a date to 00:00:00
    */
    private function resetTimeToMidnight($date)
    {
    if (!empty($date)) {
    // Assuming $date is a timestamp or string in format compatible with strtotime
    return dol_mktime(0, 0, 0, dol_print_date($date, '%m'), dol_print_date($date, '%d'), dol_print_date($date, '%Y'),'gmt');
    }
    return $date; // Return unchanged if date is empty or null
    }

@josett225
Copy link
Contributor Author

Hi @eldy
The errors are neither in Asset Module nor in my code.

@eldy eldy merged commit c32f31b into Dolibarr:develop Dec 13, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants