Skip to content

Commit

Permalink
Update DateTimeFormatter.cs
Browse files Browse the repository at this point in the history
Fixed: Setting the value to null didn't clear the minute component
  • Loading branch information
Mehrzad Chehraz committed Oct 12, 2015
1 parent b23512b commit 8a2f83a
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions Atf.Core.Text/DateTimeFormatter.cs
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2015 Mehrzad Chehraz (mehrzady@gmail.com)
* Released under the MIT License
* http://chehraz.ir/mit_license
Expand Down Expand Up @@ -221,29 +221,7 @@ public struct SpecifierInfo {
}
#endregion

#region Methods
private void SetDateTimeComponents() {
if (this.value.HasValue) {
DateTime _value = this.value.Value;
Calendar calendar = this.Calendar;
this.day = calendar.GetDayOfMonth(_value);
this.hour = calendar.GetHour(_value);
this.minute = calendar.GetMinute(_value);
this.month = calendar.GetMonth(_value);
this.second = calendar.GetSecond(_value);
this.year = calendar.GetYear(_value);
this.am = this.hour < 12;
}
else {
this.day =
this.hour =
this.month =
this.month =
this.second =
this.year = null;
this.am = true;
}
}
#region Methods
public void ClearComponentValue(SpecifierInfo specifier) {
switch (specifier.Type) {
case SpecifierType.s:
Expand Down Expand Up @@ -944,6 +922,28 @@ public struct SpecifierInfo {
}
return null;
}
private void SetDateTimeComponents() {
if (this.value.HasValue) {
DateTime _value = this.value.Value;
Calendar calendar = this.Calendar;
this.day = calendar.GetDayOfMonth(_value);
this.hour = calendar.GetHour(_value);
this.minute = calendar.GetMinute(_value);
this.month = calendar.GetMonth(_value);
this.second = calendar.GetSecond(_value);
this.year = calendar.GetYear(_value);
this.am = this.hour < 12;
}
else {
this.day =
this.hour =
this.minute =
this.month =
this.second =
this.year = null;
this.am = true;
}
}
private static bool ShouldCommit(int? dateTimeValue, int? value) {
if (dateTimeValue.HasValue) {
return !value.HasValue || !dateTimeValue.Value.Equals(value.Value);
Expand Down

0 comments on commit 8a2f83a

Please sign in to comment.