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

RetentionUntilDate in SetObjectRetentionArgs serialized to wrong value #810

Closed
basrach opened this issue Jul 31, 2023 · 0 comments · Fixed by #811
Closed

RetentionUntilDate in SetObjectRetentionArgs serialized to wrong value #810

basrach opened this issue Jul 31, 2023 · 0 comments · Fixed by #811

Comments

@basrach
Copy link
Contributor

basrach commented Jul 31, 2023

When RetentionUntilDate property in SetObjectRetentionArgs class serialized, it formatted to ISO 8601 string, but time zone offset get lost.

public static string To8601String(DateTime dt)
{
    return dt.ToString("yyyy-MM-dd'T'HH:mm:ssZ", CultureInfo.InvariantCulture);
}

As result if date in local time zone, minio server received date in past or future depending on time zone.
I tried pass date in UTC, but get error, because passed value checked against local time (DateTime.Now) always

if (DateTime.Compare(RetentionUntilDate, DateTime.Now) <= 0)
            throw new InvalidOperationException("Retention until date set using " + nameof(WithRetentionUntilDate) +
                                                " needs to be in the future.");
adcy added a commit to adcy/minio-dotnet that referenced this issue Jul 31, 2023
ebozduman added a commit that referenced this issue Aug 9, 2023
* Fixed time zone lost when serializing and parsing dates

Fixes #810 and #808

* code style fix

* required lint changes

---------

Co-authored-by: Andrey <42999852+adcy@users.noreply.github.com>
Co-authored-by: Ersan Bozduman <ersanbozduman@gmail.com>
Co-authored-by: ebozduman <ersan.bozduman@gmail.com>
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 a pull request may close this issue.

1 participant