choptastic / qdate

Erlang date, time, and timezone management: formatting, conversion, and date arithmetic
http://sigma-star.com/blog/post/qdate
MIT License
247 stars 82 forks source link

Support character escaping #6

Closed stwind closed 10 years ago

stwind commented 10 years ago

Currently there is no way to print a literal format character, because qdate:to_string_worker/4 aggressively parses them before ec_date:format/3 can escape them.

1> qdate:to_string("Y").
"2014"
2> qdate:to_string("\\Y").
"\\2014"

This patch will do a same thing as ec_date, escaping format character with \\.

1> qdate:to_string("Y").
"2014"
2> qdate:to_string("\\Y").
"Y"
3> qdate:to_string("Z").
"+0"
4> qdate:to_string("\\Z").
"Z"
choptastic commented 10 years ago

Thanks so much for the code contribution!