- String: Implement String != regex operator
- String: index and rindex methods with String argument
- String: format operator % like in python
-- String: split and join
- String: assign fstream objects to read and write a file
- String: convert to and from std::sstream and std::string
- regex: throw an exception when contructing a regex returns an error
- date: Parser for stream input
- date: Yearday, Weekday and week number
-- UTC: Convert to and from time_t, struct tm
+- UTC: Convert to and from struct tm
- xml: Add access to attributes
- xml: Xinclude processing
hour(String s);
+ operator long()
+ {
+ return hours * 3600 + minutes * 60 + seconds;
+ }
+
bool proper(); // Check wether this is a proper clock time
// Attributes.
friend UTC operator+(UTC &, UTC &);
UTC operator += (UTC h);
+ friend long operator-(UTC &, UTC &);
+
friend std::ostream& operator<<(std::ostream &, const UTC &);
friend std::istream& operator>>(std::istream &, UTC &);
return *this;
}
+long operator-(UTC &u1, UTC &u2)
+{
+ long days;
+ long seconds;
+
+ days = u1.d - u2.d;
+ seconds = long(u1.t) - long(u2.t);
+
+ return days * 24 * 60 * 60 + seconds;
+}
+
std::ostream& operator<<(std::ostream &s, const UTC &t)
{
s << t.d << " " << t.t;
assert(h5.Minute() == 23);
assert(h5.Second() == 20);
+ long l5;
+
+ l5 = (long)h5;
+ std::cout << h5 << " = " << l5 << " seconds.\n";
+ assert(l5 == 5000);
+
return 0;
}
Copy contructor from 15:20:45: "15:20:45"
Assigned from 15:20:45: "15:20:45"
5000 seconds = 01:23:20
+01:23:20 = 5000 seconds.
PASS hour_assign (exit status: 0)
std::cout.flush();
assert(d1 == UTC(date(22, 7, 2023), t0));
+ // Calculate the number of seconds between 2 UTC objects.
+
+ date d3(2, 2, 2020);
+ hour h3(10, 0, 0);
+ UTC u3(d3, h3);
+ date d4(4, 2, 2020);
+ hour h4(20, 0, 0);
+ UTC u4(d4, h4);
+
+ long l4 = u4 - u3;
+ std::cout << "From " << u3 << " to " << u4 << " takes " << l4 << " seconds\n";
+ assert(l4 == 208800);
+
return 0;
}
09-06-2019 00:00:00 + 05-03-6 00:00:00 = 14-09-2025 00:00:00
09-06-2019 00:00:00 + 30-11-3 00:00:00 = 08-06-2023 00:00:00
22-07-2019 00:00:00 += 30-11-3 00:00:00 = 22-07-2023 00:00:00
+From 02-02-2020 10:00:00 to 04-02-2020 20:00:00 takes 208800 seconds
PASS utc_arithmetic (exit status: 0)