Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions main/SS/Formula/Functions/EDate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions main/Util/StringUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
18 changes: 11 additions & 7 deletions openxml4Net/OPC/Internal/PackagePropertiesPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public Nullable<DateTime> GetModifiedProperty() {
* @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);
Expand Down Expand Up @@ -570,10 +570,12 @@ private String SetStringValue(String s) {
{
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);
}
}
}
Expand All @@ -582,10 +584,12 @@ private String SetStringValue(String s) {
{
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
Expand Down