uptime.c
changeset 10 36e7f4269583
parent 9 c1f0277182a3
child 11 431de0cc8126
equal deleted inserted replaced
9:c1f0277182a3 10:36e7f4269583
     1 
     1 
     2 /* Copyright 2010 Myhailo Danylenko
     2 /* Copyright 2010 Myhailo Danylenko
       
     3  * Copyright 2010 Mikael Berthe
     3  *
     4  *
     4  * This file is part of mcabber-uptime
     5  * This file is part of mcabber-uptime
     5  *
     6  *
     6  * mcabber-uptime is free software: you can redistribute it and/or modify
     7  * mcabber-uptime is free software: you can redistribute it and/or modify
     7  * it under the terms of the GNU General Public License as published by
     8  * it under the terms of the GNU General Public License as published by
   109 	seconds %= 60;
   110 	seconds %= 60;
   110 	minutes %= 60;
   111 	minutes %= 60;
   111 	hours   %= 24;
   112 	hours   %= 24;
   112 
   113 
   113 	if (days)
   114 	if (days)
   114 		g_string_append_printf (line, " %u days", days);
   115 		g_string_append_printf (line, " %u day%c", days,
       
   116 				days > 1 ? 's' : ' ');
   115 	if (hours)
   117 	if (hours)
   116 		g_string_append_printf (line, " %u hours", hours);
   118 		g_string_append_printf (line, " %u hour%c", hours,
       
   119 				hours > 1 ? 's' : ' ');
   117 	if (minutes)
   120 	if (minutes)
   118 		g_string_append_printf (line, " %u minutes", minutes);
   121 		g_string_append_printf (line, " %u minute%c", minutes,
       
   122 				minutes > 1 ? 's' : ' ');
   119 	if (seconds)
   123 	if (seconds)
   120 		g_string_append_printf (line, " %u seconds", seconds);
   124 		g_string_append_printf (line, " %u second%s", seconds,
       
   125 				seconds > 1 ? "s." : ".");
   121 
   126 
   122 	// Running since:
   127 	// Running since:
   123 	strftime(strstartdate, sizeof(strstartdate),
   128 	strftime(strstartdate, sizeof(strstartdate),
   124 			"%Y-%m-%d %H:%M", localtime(&starttime));
   129 			"%Y-%m-%d %H:%M", localtime(&starttime));
   125 
   130 
   126 	scr_log_print (LPRINT_NORMAL, "Uptime: %s.\n(Running since %s)",
   131 	scr_log_print (LPRINT_NORMAL, "Uptime: %s\n(Running since %s)",
   127 			line -> len ? line -> str : " 0 second",
   132 			line -> len ? line -> str : " 0 second.",
   128 			strstartdate);
   133 			strstartdate);
   129 
   134 
   130 	g_string_free (line, TRUE);
   135 	g_string_free (line, TRUE);
   131 }
   136 }
   132 
   137