Reputation: 13739
According to the valadoc
var now = new DateTime.now(new TimeZone.local());
var timestamp = now.format("\%F.\%T");
should set timestamp to "2012-08-28.09:51:06." Why "error: invalid escape sequence" on "F" and "T?" Other formats from the valadoc cause the same error and now.to_string() is in fact "2012-08-28T09:51:06+0000"
Edit: Perhaps embedded-linux target is missing something?
Edit: The test code here prints "(null)" in this project which uses glib 2.26.1.
Upvotes: 2
Views: 298
Reputation: 17502
As NullUserException mentioned, you shouldn't be including the backslashes--that is what is causing the invalid escape sequence error.
The reason it still doesn't work after removing the backslashes is that the %T format specifier wasn't added until the 2.30 cycle. The relevant commit is 414c8ce532c19fe65deb8dfb80222d0164be5cbe
You can work around it by doing something like this instead:
var timestamp = now.format ("%F.%H:%M:%S");
Upvotes: 2