* do not throw IndexOutOfBounds when AM/PM designator is empty
* store am/pm designator in local
// change the code below.
if (str.GetNext())
{
- if (str.GetChar() == dtfi.AMDesignator[0])
+ string amDesignator = dtfi.AMDesignator;
+ if (amDesignator.Length > 0 && str.GetChar() == amDesignator[0])
{
result = TM.AM;
- return (true);
+ return true;
}
- if (str.GetChar() == dtfi.PMDesignator[0])
+
+ string pmDesignator = dtfi.PMDesignator;
+ if (pmDesignator.Length > 0 && str.GetChar() == pmDesignator[0])
{
result = TM.PM;
- return (true);
+ return true;
}
}
return false;