package org.mtransit.parser.mt.data;

public class MServiceDate implements Comparable<MServiceDate> {

	public String serviceId;
	public int calendarDate;

	public MServiceDate(String serviceId, int calendarDate) {
		this.serviceId = serviceId;
		this.calendarDate = calendarDate;
	}

	@Override
	public int compareTo(MServiceDate otherServiceDate) {
		return calendarDate - otherServiceDate.calendarDate;
	}

	@Override
	public boolean equals(Object obj) {
		MServiceDate ts = (MServiceDate) obj;
		if (ts.serviceId != null && !ts.serviceId.equals(serviceId)) {
			return false;
		}
		if (ts.calendarDate != 0 && ts.calendarDate != calendarDate) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return new StringBuilder() //
				.append('\'').append(MSpec.escape(serviceId)).append('\'').append(',') // service ID
				.append(calendarDate) // calendar date
				.toString();
	}

}

@@ -346,22 +346,30 @@
 te) %7B%0A%09%09
-return
+final int cd =
  calenda
@@ -399,32 +399,135 @@
 e.calendarDate;%0A
+%09%09if (cd != 0) %7B%0A%09%09%09return cd;%0A%09%09%7D%0A%09%09return serviceId.compareToIgnoreCase(otherServiceDate.serviceId);%0A
 %09%7D%0A%0A%09@Override%0A%09

Fix service date sorting when multiple services / day.