Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision b7fd2a02e4161f4edd38548e7f8456b8021549be)
+++ uspace/lib/c/generic/time.c	(revision 75701004b4fe1a0a5f2b92aef205e5bfbf9a69e3)
@@ -82,14 +82,14 @@
 {
 	year += 1900;
-	
+
 	if (year % 400 == 0)
 		return true;
-	
+
 	if (year % 100 == 0)
 		return false;
-	
+
 	if (year % 4 == 0)
 		return true;
-	
+
 	return false;
 }
@@ -110,9 +110,9 @@
 	assert(mon >= 0);
 	assert(mon <= 11);
-	
+
 	static int month_days[] = {
 		31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
 	};
-	
+
 	if (mon == 1) {
 		/* February */
@@ -120,5 +120,5 @@
 		return is_leap_year(year) ? 29 : 28;
 	}
-	
+
 	return month_days[mon];
 }
@@ -144,9 +144,9 @@
 		0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
 	};
-	
+
 	static int leap_mdays[] = {
 		0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
 	};
-	
+
 	return (is_leap_year(year) ? leap_mdays[mon] : mdays[mon]) + mday - 1;
 }
@@ -166,5 +166,5 @@
 	if ((op1 >= 0) || (op1 % op2 == 0))
 		return op1 / op2;
-	
+
 	return op1 / op2 - 1;
 }
@@ -183,17 +183,17 @@
 {
 	time_t div = floor_div(op1, op2);
-	
+
 	/*
 	 * (a / b) * b + a % b == a
 	 * Thus: a % b == a - (a / b) * b
 	 */
-	
+
 	time_t result = op1 - div * op2;
-	
+
 	/* Some paranoid checking to ensure there is mistake here. */
 	assert(result >= 0);
 	assert(result < op2);
 	assert(div * op2 + result == op1);
-	
+
 	return result;
 }
@@ -261,5 +261,5 @@
 {
 	// TODO: DST correction
-	
+
 	/* Set initial values. */
 	time_t usec = tm->tm_usec + tv->tv_usec;
@@ -270,5 +270,5 @@
 	time_t mon = tm->tm_mon;
 	time_t year = tm->tm_year;
-	
+
 	/* Adjust time. */
 	sec += floor_div(usec, USECS_PER_SEC);
@@ -280,15 +280,15 @@
 	day += floor_div(hour, HOURS_PER_DAY);
 	hour = floor_mod(hour, HOURS_PER_DAY);
-	
+
 	/* Adjust month. */
 	year += floor_div(mon, 12);
 	mon = floor_mod(mon, 12);
-	
+
 	/* Now the difficult part - days of month. */
-	
+
 	/* First, deal with whole cycles of 400 years = 146097 days. */
 	year += floor_div(day, 146097) * 400;
 	day = floor_mod(day, 146097);
-	
+
 	/* Then, go in one year steps. */
 	if (mon <= 1) {
@@ -305,10 +305,10 @@
 		}
 	}
-	
+
 	/* Finally, finish it off month per month. */
 	while (day >= days_in_month(year, mon)) {
 		day -= days_in_month(year, mon);
 		mon++;
-		
+
 		if (mon >= 12) {
 			mon -= 12;
@@ -316,9 +316,9 @@
 		}
 	}
-	
+
 	/* Calculate the remaining two fields. */
 	tm->tm_yday = day_of_year(year, mon, day + 1);
 	tm->tm_wday = day_of_week(year, mon, day + 1);
-	
+
 	/* And put the values back to the struct. */
 	tm->tm_usec = (int) usec;
@@ -328,5 +328,5 @@
 	tm->tm_mday = (int) day + 1;
 	tm->tm_mon = (int) mon;
-	
+
 	/* Casts to work around POSIX brain-damage. */
 	if (year > ((int) INT_MAX) || year < ((int) INT_MIN)) {
@@ -334,5 +334,5 @@
 		return -1;
 	}
-	
+
 	tm->tm_year = (int) year;
 	return 0;
@@ -363,5 +363,5 @@
 {
 	int start_wday = day_of_week(year, 0, 1);
-	
+
 	return floor_mod(4 - start_wday, 7) - 3;
 }
@@ -377,15 +377,15 @@
 {
 	int day = tm->tm_yday - wbyear_offset(tm->tm_year);
-	
+
 	if (day < 0) {
 		/* Last week of previous year. */
 		return tm->tm_year - 1;
 	}
-	
+
 	if (day > 364 + is_leap_year(tm->tm_year)) {
 		/* First week of next year. */
 		return tm->tm_year + 1;
 	}
-	
+
 	/* All the other days are in the calendar year. */
 	return tm->tm_year;
@@ -405,5 +405,5 @@
 {
 	int first_day = (7 - day_of_week(tm->tm_year, 0, 1)) % 7;
-	
+
 	return (tm->tm_yday - first_day + 7) / 7;
 }
@@ -425,15 +425,15 @@
 {
 	int day = tm->tm_yday - wbyear_offset(tm->tm_year);
-	
+
 	if (day < 0) {
 		/* Last week of previous year. */
 		return 53;
 	}
-	
+
 	if (day > 364 + is_leap_year(tm->tm_year)) {
 		/* First week of next year. */
 		return 1;
 	}
-	
+
 	/* All the other days give correct answer. */
 	return (day / 7 + 1);
@@ -453,5 +453,5 @@
 {
 	int first_day = (1 - day_of_week(tm->tm_year, 0, 1)) % 7;
-	
+
 	return (tm->tm_yday - first_day + 7) / 7;
 }
@@ -535,8 +535,8 @@
 	if (tv1->tv_sec > tv2->tv_sec)
 		return true;
-	
+
 	if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec > tv2->tv_usec))
 		return true;
-	
+
 	return false;
 }
@@ -555,8 +555,8 @@
 	if (tv1->tv_sec > tv2->tv_sec)
 		return true;
-	
+
 	if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec >= tv2->tv_usec))
 		return true;
-	
+
 	return false;
 }
@@ -582,5 +582,5 @@
 		tz->tz_dsttime = DST_NONE;
 	}
-	
+
 	if (clock_conn == NULL) {
 		category_id_t cat_id;
@@ -588,5 +588,5 @@
 		if (rc != EOK)
 			goto fallback;
-		
+
 		service_id_t *svc_ids;
 		size_t svc_cnt;
@@ -594,8 +594,8 @@
 		if (rc != EOK)
 			goto fallback;
-		
+
 		if (svc_cnt == 0)
 			goto fallback;
-		
+
 		char *svc_name;
 		rc = loc_service_get_name(svc_ids[0], &svc_name);
@@ -603,5 +603,5 @@
 		if (rc != EOK)
 			goto fallback;
-		
+
 		service_id_t svc_id;
 		rc = loc_service_get_id(svc_name, &svc_id, 0);
@@ -609,5 +609,5 @@
 		if (rc != EOK)
 			goto fallback;
-		
+
 		clock_conn = loc_service_connect(svc_id, INTERFACE_DDF,
 		    IPC_FLAG_BLOCKING);
@@ -615,15 +615,15 @@
 			goto fallback;
 	}
-	
+
 	struct tm time;
 	errno_t rc = clock_dev_time_get(clock_conn, &time);
 	if (rc != EOK)
 		goto fallback;
-	
+
 	tv->tv_usec = time.tm_usec;
 	tv->tv_sec = mktime(&time);
-	
+
 	return;
-	
+
 fallback:
 	getuptime(tv);
@@ -639,5 +639,5 @@
 			goto fallback;
 		}
-		
+
 		void *addr = AS_AREA_ANY;
 		rc = physmem_map(faddr, 1, AS_AREA_READ | AS_AREA_CACHEABLE,
@@ -648,16 +648,16 @@
 			goto fallback;
 		}
-		
+
 		ktime = addr;
 	}
-	
+
 	sysarg_t s2 = ktime->seconds2;
-	
+
 	read_barrier();
 	tv->tv_usec = ktime->useconds;
-	
+
 	read_barrier();
 	sysarg_t s1 = ktime->seconds1;
-	
+
 	if (s1 != s2) {
 		tv->tv_sec = max(s1, s2);
@@ -665,7 +665,7 @@
 	} else
 		tv->tv_sec = s1;
-	
+
 	return;
-	
+
 fallback:
 	tv->tv_sec = 0;
@@ -677,8 +677,8 @@
 	struct timeval tv;
 	gettimeofday(&tv, NULL);
-	
+
 	if (tloc)
 		*tloc = tv.tv_sec;
-	
+
 	return tv.tv_sec;
 }
@@ -706,5 +706,5 @@
 	// TODO: take DST flag into account
 	// TODO: detect overflow
-	
+
 	normalize_tm_time(tm, 0);
 	return secs_since_epoch(tm);
@@ -755,33 +755,33 @@
 	assert(format != NULL);
 	assert(tm != NULL);
-	
+
 	// TODO: use locale
-	
+
 	static const char *wday_abbr[] = {
 		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 	};
-	
+
 	static const char *wday[] = {
 		"Sunday", "Monday", "Tuesday", "Wednesday",
 		"Thursday", "Friday", "Saturday"
 	};
-	
+
 	static const char *mon_abbr[] = {
 		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
 		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 	};
-	
+
 	static const char *mon[] = {
 		"January", "February", "March", "April", "May", "June", "July",
 		"August", "September", "October", "November", "December"
 	};
-	
+
 	if (maxsize < 1)
 		return 0;
-	
+
 	char *ptr = s;
 	size_t consumed;
 	size_t remaining = maxsize;
-	
+
 	while (*format != '\0') {
 		if (*format != '%') {
@@ -790,5 +790,5 @@
 			continue;
 		}
-		
+
 		format++;
 		if ((*format == '0') || (*format == '+')) {
@@ -796,15 +796,15 @@
 			format++;
 		}
-		
+
 		while (isdigit(*format)) {
 			// TODO: padding
 			format++;
 		}
-		
+
 		if ((*format == 'O') || (*format == 'E')) {
 			// TODO: locale's alternative format
 			format++;
 		}
-		
+
 		switch (*format) {
 		case 'a':
@@ -938,12 +938,12 @@
 			while (*format != '%')
 				format--;
-			
+
 			APPEND("%%");
 			break;
 		}
-		
+
 		format++;
 	}
-	
+
 	return maxsize - remaining;
 }
@@ -960,5 +960,5 @@
 {
 	assert(result != NULL);
-	
+
 	/* Set result to epoch. */
 	result->tm_usec = 0;
@@ -969,8 +969,8 @@
 	result->tm_mon = 0;
 	result->tm_year = 70; /* 1970 */
-	
+
 	if (normalize_tm_time(result, time) == -1)
 		return EOVERFLOW;
-	
+
 	return EOK;
 }
@@ -993,5 +993,5 @@
 	if (ret != EOK)
 		return ret;
-	
+
 	time_tm2str(&tm, buf);
 	return EOK;
@@ -1011,14 +1011,14 @@
 	assert(timeptr != NULL);
 	assert(buf != NULL);
-	
+
 	static const char *wday[] = {
 		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 	};
-	
+
 	static const char *mon[] = {
 		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
 		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 	};
-	
+
 	snprintf(buf, ASCTIME_BUF_LEN, "%s %s %2d %02d:%02d:%02d %d\n",
 	    wday[timeptr->tm_wday],
@@ -1043,5 +1043,5 @@
 	// TODO: Deal with timezones.
 	//       Currently assumes system and all times are in UTC
-	
+
 	/* Set result to epoch. */
 	result->tm_usec = 0;
@@ -1052,8 +1052,8 @@
 	result->tm_mon = 0;
 	result->tm_year = 70; /* 1970 */
-	
+
 	if (normalize_tm_tv(result, tv) == -1)
 		return EOVERFLOW;
-	
+
 	return EOK;
 }
@@ -1097,5 +1097,5 @@
 	if (ret != EOK)
 		return ret;
-	
+
 	time_tm2str(&loctime, buf);
 	return EOK;
