1 /* 2 * Copyright (C) 2011 Red Hat, Inc. 3 * 4 * This library is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as 6 * published by the Free Software Foundation; either version 2.1 of the 7 * licence, or (at your option) any later version. 8 * 9 * This is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 12 * License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this library; if not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include <locale.h> 19 #include <glib/glib.h> 20 21 int main(int argc,char * argv[])22main (int argc, char *argv[]) 23 { 24 gchar *fmt; 25 GDateTime *dt; 26 gchar *str; 27 28 setlocale (LC_ALL, ""); 29 30 if (argc > 1) 31 fmt = argv[1]; 32 else 33 fmt = "%x %X"; 34 35 dt = g_date_time_new_now_local (); 36 str = g_date_time_format (dt, fmt); 37 g_print ("%s\n", str); 38 g_free (str); 39 g_date_time_unref (dt); 40 41 return 0; 42 } 43