> On May 20, 2015, 7:10 a.m., Nikita Vetoshkin wrote: > > 3rdparty/libprocess/include/process/http.hpp, line 352 > > <https://reviews.apache.org/r/30032/diff/7/?file=963338#file963338line352> > > > > strftime formatting is locale dependent. This example > > ``` > > #include <locale.h> > > #include <time.h> > > #include <stdio.h> > > > > > > int main() { > > char outstr[200]; > > time_t t; > > struct tm *tmp; > > > > const char HTTP_DATE[] = "%a, %d %b %Y %T %Z"; > > > > setlocale(LC_ALL, "ru_RU.UTF-8"); > > > > t = time(NULL); > > tmp = localtime(&t); > > > > strftime(outstr, sizeof(outstr), HTTP_DATE, tmp); > > > > printf("Result string is \"%s\"\n", outstr); > > > > } > > ``` > > on my laptop produces > > ``` > > Result string is "??, 20 ??? 2015 10:04:43 YEKT" > > ``` > > Don't know if it is an issue, maybe process should call > > `setlocale(LC_ALL, "C");` or add a TODO? > > Nikita Vetoshkin wrote: > I think this approuch should work regardless locale being used > > ``` > #include <locale.h> > #include <time.h> > #include <stdio.h> > > > int main() { > char outstr[200]; > time_t t; > struct tm *date; > > const char *WEEK_DAYS[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", > "Sun"}; > const char *MONTHS[] = { > "Jan", "Feb", > "Mar", "Apr", "May", > "Jun", "Jul", "Aug", > "Sep", "Oct", "Nov", > "Dec"}; > const char FORMAT[] = "%s, %02d %s %d %02d:%02d:%02d GMT"; > > setlocale(LC_ALL, "ru_RU.UTF-8"); > > t = time(NULL); > date = gmtime(&t); > > snprintf(outstr, sizeof(outstr), FORMAT, > WEEK_DAYS[date->tm_wday], > date->tm_mday, > MONTHS[date->tm_mon], > date->tm_year + 1900, > date->tm_hour, > date->tm_min, > date->tm_sec); > > printf("Result string is \"%s\"\n", outstr); > } > ```
Yeah, the problem is, there are more places in the code base using strftime, so I started a discussion in the dev list and see what happens there. - Alexander ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/30032/#review84465 ----------------------------------------------------------- On May 19, 2015, 6:20 a.m., Alexander Rojas wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/30032/ > ----------------------------------------------------------- > > (Updated May 19, 2015, 6:20 a.m.) > > > Review request for mesos, Benjamin Hindman, Bernd Mathiske, Joerg Schad, > Michael Park, and Till Toenshoff. > > > Bugs: mesos-708 > https://issues.apache.org/jira/browse/mesos-708 > > > Repository: mesos > > > Description > ------- > > When serving a static file, libprocess returns the header `Last-Modified` > which is used by browsers to control Cache. > When a http request arrives containing the header `If-Modified-Since`, a > response `304 Not Modified` is returned if the date in the request and the > modification time (as returned by doing `stat` in the file) coincide. > Unit tests added. > > > Diffs > ----- > > 3rdparty/libprocess/include/process/http.hpp > bba62b393dc863e724cb602b1504eb6517ae9730 > 3rdparty/libprocess/src/process.cpp > e3de3cd6b536aaaf59784360aed546512dd04dc9 > 3rdparty/libprocess/src/tests/process_tests.cpp > 67e582cc250a9767a389e2bd0cc68985477f3ffb > > Diff: https://reviews.apache.org/r/30032/diff/ > > > Testing > ------- > > make check > > > Thanks, > > Alexander Rojas > >
