protected DatePeriod parseDatePeriod(String[] words, int code)
			throws MalformedDateException {
		int toOffset = 0;
		Date date1 = null;
		Date date2 = null;

		if (code == FROM)
			for (int i = 1; i < words.length; i++) {
				if (words[i].equalsIgnoreCase("TO")) {
					toOffset = i;
					break;
				}
			}

		int flags = 0;
		
		if (toOffset > 0) {
			date1 = parsePlainDate(words, 1, toOffset - 1);
			date2 = parsePlainDate(words, toOffset + 1, 0);
			flags = DatePeriod.FROM_TO;
		} else {
			date1 = parsePlainDate(words, 1, 0);
			flags = (code == FROM) ? DatePeriod.FROM : DatePeriod.TO;
		}

		return new DatePeriod(date1, date2, flags);
	}