parse method

  1. @override
int parse(
  1. String input
)
override

Parses input and returns the numeric value.

Throws FormatException when input cannot be parsed by this codec.

Implementation

@override
int parse(String input) {
  var text = input.trim();
  if (suffix.isNotEmpty) {
    if (!text.endsWith(suffix)) {
      throw FormatException('Expected year suffix "$suffix".', input);
    }
    text = text.substring(0, text.length - suffix.length);
  }

  final value = _cardinal.parse(text);
  if (value < 0) {
    throw FormatException('Expected a non-negative French year.', input);
  }
  return value;
}