12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
15 |
*/ |
*/ |
|
|
|
16 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
17 |
#include <config.h> |
#include <config.h> |
18 |
#endif |
#endif |
534 |
|
|
535 |
|
|
536 |
/* Return date in a format which complies with the |
/* Return date in a format which complies with the |
537 |
system locale settings. */ |
locale user settings. */ |
538 |
const char* |
const char* |
539 |
get_locale_date (long tm_t, char *buf, DWORD buflen) |
get_locale_date (long tm_t, char *buf, DWORD buflen) |
540 |
{ |
{ |
541 |
SYSTEMTIME st; |
SYSTEMTIME st; |
542 |
struct tm *ptm; |
struct tm *ptm; |
543 |
|
|
544 |
ptm = localtime (&tm_t); |
ptm = localtime (&tm_t); |
545 |
st.wYear = (WORD)ptm->tm_year; |
memset (&st, 0, sizeof (st)); |
546 |
st.wMonth = (WORD)ptm->tm_mon; |
st.wYear = (WORD)ptm->tm_year+1900; |
547 |
|
st.wMonth = (WORD)ptm->tm_mon+1; |
548 |
st.wDay = (WORD)ptm->tm_mday; |
st.wDay = (WORD)ptm->tm_mday; |
|
st.wYear += 1900; |
|
|
st.wMonth += 1; |
|
549 |
if (!GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, |
if (!GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, |
550 |
NULL, buf, buflen)) |
NULL, buf, buflen)) |
551 |
return NULL; |
return NULL; |
552 |
return buf; |
return buf; |
553 |
} |
} |
554 |
|
|
555 |
|
/* Return the time in a format which complies with the locale user |
556 |
|
settings. */ |
557 |
|
const char* |
558 |
|
get_locale_time (long tm_t, char *buf, DWORD buflen) |
559 |
|
{ |
560 |
|
SYSTEMTIME st; |
561 |
|
struct tm *ptm; |
562 |
|
|
563 |
|
ptm = localtime (&tm_t); |
564 |
|
memset (&st, 0, sizeof (st)); |
565 |
|
st.wMinute = (WORD)ptm->tm_min; |
566 |
|
st.wHour = (WORD)ptm->tm_hour; |
567 |
|
st.wSecond = (WORD)ptm->tm_sec; |
568 |
|
|
569 |
|
if (!GetTimeFormat (LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT, &st, |
570 |
|
NULL, buf, buflen)) |
571 |
|
return NULL; |
572 |
|
return buf; |
573 |
|
} |
574 |
|
|
575 |
|
|
576 |
|
/* Return a combination of date+time which complies to the |
577 |
|
local user settings. */ |
578 |
|
const char* |
579 |
|
get_locale_timedate (long tm_t, char *buf, DWORD buflen) |
580 |
|
{ |
581 |
|
DWORD nleft = buflen; |
582 |
|
|
583 |
|
if (!get_locale_date (tm_t, buf, buflen)) |
584 |
|
return NULL; |
585 |
|
nleft -= strlen (buf)+1; |
586 |
|
if (nleft < 1) |
587 |
|
return NULL; |
588 |
|
strcat (buf, " "); |
589 |
|
nleft--; |
590 |
|
if (!get_locale_time (tm_t, buf+strlen (buf), nleft)) |
591 |
|
return NULL; |
592 |
|
return buf; |
593 |
|
} |
594 |
|
|
595 |
|
|
596 |
/* Generate a temporary file name by using the users |
/* Generate a temporary file name by using the users |
597 |
temp path and optionally a name @name provided by the caller. |
temp path and optionally a name @name provided by the caller. |
640 |
void |
void |
641 |
ComboBox_AddString_utf8 (HWND cb, const char *txt) |
ComboBox_AddString_utf8 (HWND cb, const char *txt) |
642 |
{ |
{ |
|
|
|
643 |
char *utf8_txt; |
char *utf8_txt; |
644 |
|
|
645 |
utf8_txt = utf8_to_native (txt); |
utf8_txt = utf8_to_native (txt); |