未验证 提交 a77b0b94 编写于 作者: T Tony Qu 提交者: GitHub

Merge pull request #1141 from karakasa/fix_compare_to_null_bug

Fix warnings on comparing value types to null
......@@ -59,11 +59,16 @@ public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec)
int offsetInMonthAsNumber = (int)GetValue(args[1]);
// resolve the arguments
DateTime startDate = DateUtil.GetJavaDate(startDateAsNumber);
if (startDate == null)
DateTime startDate;
try
{
startDate = DateUtil.GetJavaDate(startDateAsNumber);
}
catch (ArgumentException)
{
return ErrorEval.VALUE_INVALID;
}
DateTime resultDate = startDate.AddMonths(offsetInMonthAsNumber);
result = DateUtil.GetExcelDate(resultDate);
......
......@@ -510,8 +510,8 @@ public static String MapMsCodepointString(String string1)
{
int msCodepoint = char.ConvertToUtf32(string1, offset);//codePointAt(stringChars, offset, string1.Length);
int uniCodepoint = msCodepointToUnicode[(msCodepoint)];
sb.Append(Char.ConvertFromUtf32(uniCodepoint == null ? msCodepoint : uniCodepoint));
sb.Append(Char.ConvertFromUtf32(msCodepointToUnicode.TryGetValue(msCodepoint, out var uniCodepoint) ? uniCodepoint : msCodepoint));
offset += CharCount(msCodepoint);
}
......
......@@ -309,7 +309,7 @@ public PackagePropertiesPart(OPCPackage pack, PackagePartName partName)
* @return A string representation of the modified date.
*/
public String GetModifiedPropertyString() {
if (modified.Value == null)
if (modified == null)
return GetDateValue(new Nullable<DateTime>(new DateTime()));
else
return GetDateValue(modified);
......@@ -570,10 +570,12 @@ public PackagePropertiesPart(OPCPackage pack, PackagePartName partName)
{
SimpleDateFormat df = new SimpleDateFormat(fStr);
df.TimeZone = TimeZoneInfo.Utc;
DateTime d = df.Parse(dateTzStr);
if (d != null)
try
{
return df.Parse(dateTzStr);
}
catch (FormatException)
{
return new DateTime?(d);
}
}
}
......@@ -582,10 +584,12 @@ public PackagePropertiesPart(OPCPackage pack, PackagePartName partName)
{
SimpleDateFormat df = new SimpleDateFormat(fStr);
df.TimeZone = TimeZoneInfo.Utc;
DateTime d = df.Parse(dateTzStr).ToUniversalTime();
if (d != null)
try
{
return df.Parse(dateTzStr).ToUniversalTime();
}
catch (FormatException)
{
return new DateTime?(d);
}
}
//if you're here, no pattern matched, throw exception
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册