Is it possible to get a date as a string in other languages than english?
For Example:
The command strftime can give me a string like this: 'Wednesday, 18.07.01'
But I would need the weekday (and month) in the language that the system
(Windows) is set up.
So it should be 'Mittwoch, 18.07.01' on a german Windows.
I would need a solution that also works with other languages (German,
Afrikaans, Chinese,...)
Please help me if you can!
Mike
I am not sure what is available for the newer compilers.
Craig...
"Fieger Michael" <michael...@isagmbh.at> wrote in message
news:3b559dff_1@dnews...
Look into locales; if bc++ doesn't support them, try something like
this (with trivial changes to make it compile with pre-standard bc++).
I think anyone outside the US can read this already, and we'll get
there eventually too.
#include <cassert>
#include <cstddef>
#include <ctime>
#include <string>
std::string datestamp() // ISO8601 date and time
{
std::size_t const len = sizeof "CCYY-MM-DDTHH:MM:SSZ" / sizeof(char);
std::time_t t = std::time(0);
std::tm* gmt = std::gmtime(&t);
char s[len];
std::size_t rc = std::strftime(s, len, "%Y-%m-%dT%H:%M:%SZ", gmt);
assert(0 != rc);
return &s[0];
}
#include <iostream>
int main()
{
std::cout << datestamp() << '\n';
}
If you want a windows-specific solution, try the winapi group.
GetLocaleInfo(lcid, LOCALE_SDAYNAME1, buf, 100);
...
GetLocaleInfo(lcid, LOCALE_SDAYNAME7, buf, 100);
I don't know about Chinese and other unicode.
Regards,
Barmak
This was the solution to my problem. Works also well with Chinese!
Mike