public class Lift : Object {
public string city_from;
public string city_to;
- public string date;
- public string time;
+ public Time time;
public int places;
public string price;
public LiftFlags flags;
public string email;
public string description;
public string modified;
+
+ public Lift () {
+ time.hour = -1;
+ }
}
public class CallbackMessage : Soup.Message {
lift.city_to = n3->content;
break;
case 2:
- lift.date = n3->content;
+ parse_date (n3->content, out lift.time);
break;
case 3:
- lift.time = n3->content;
+ parse_time (n3->content.strip (), out lift.time);
break;
case 4:
lift.places = n3->content.to_int ();
var text1 = n2->children->content.strip ();
- if (text == "Datum")
- lift.date = text1;
- else if (text == "Freie Pl\xc3\xa4tze")
+ if (text == "Freie Pl\xc3\xa4tze")
lift.places = text1.to_int ();
else if (text == "Name")
lift.name = text1;
else if (text1 == "nach")
lift.city_to = text2;
else if (text1 == "Datum")
- lift.date = text2;
+ parse_date (text2, out lift.time);
else if (text1 == "Uhrzeit")
- lift.time = text2;
+ parse_time (text2, out lift.time);
else if (text1 == "Raucher")
print ("Raucher: %s\n", text2);
else if (text1 == "Fahrpreis")
Xml.Node* search_tag_by_class (Xml.Node* node, string tag, string @class) requires (node != null) {
return search_tag_by_property (node, tag, "class", @class);
}
+
+ void parse_date (string date, out Time time) {
+ int year;
+ if (date.length == 11)
+ date = date.offset (3);
+ if (date.length != 8)
+ return;
+ var res = date.scanf ("%02d.%02d.%02d", out time.day, out time.month, out year);
+ time.year = year + 2000;
+ }
+
+ void parse_time (string time, out Time result) {
+ var res = time.scanf ("%d.%02d Uhr", out result.hour, out result.minute);
+ }
}