X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fcounting.qh;h=0aeabc85e7b092e9800199fd2672c9b475a0a088;hb=7415ded9c665a49be49f4100555dfee6e0bf01b2;hp=a74f74e980f467acfe601edf823aab0c60b3ee80;hpb=3aed354c1125db3e6e862f552c253b06b09d5d86;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/counting.qh b/qcsrc/common/counting.qh index a74f74e98..0aeabc85e 100644 --- a/qcsrc/common/counting.qh +++ b/qcsrc/common/counting.qh @@ -50,7 +50,7 @@ ZCTX(_("CI_SEC^%d seconds")), /* second */ \ ZCTX(_("CI_THI^%d seconds")), /* third */ \ ZCTX(_("CI_MUL^%d seconds"))) /* multi */ - + string count_ordinal(float interval) { // This function is designed primarily for the English language, it's impossible @@ -60,10 +60,10 @@ string count_ordinal(float interval) // Basically, it just allows you to represent a number or count in different ways // depending on the number... like, with count_ordinal you can provide integers // and retrieve 1st, 2nd, 3rd, nth ordinal numbers in a clean and simple way. - if(floor((mod(interval, 100))/10) * 10 != 10) // examples: 12th, 111th, 213th will not execute this block + if(floor((interval % 100)/10) * 10 != 10) // examples: 12th, 111th, 213th will not execute this block { // otherwise, check normally for 1st,2nd,3rd insertions - switch(mod(interval, 10)) + switch(interval % 10) { case 1: return sprintf(_("%dst"), interval); case 2: return sprintf(_("%dnd"), interval); @@ -72,7 +72,7 @@ string count_ordinal(float interval) } } else { return sprintf(_("%dth"), interval); } - + return ""; } @@ -88,7 +88,7 @@ string count_fill(float interval, string zeroth, string first, string second, st // 1 second // 2 seconds // 3 seconds - // etc... minutes, hours, days, etc. + // etc... minutes, hours, days, etc. switch(floor(interval)) { @@ -111,28 +111,28 @@ string process_time(float outputtype, float seconds) { float tmp_hours = 0, tmp_minutes = 0, tmp_seconds = 0; float tmp_years = 0, tmp_weeks = 0, tmp_days = 0; - + tmp_seconds = floor(seconds); if(tmp_seconds) { tmp_minutes = floor(tmp_seconds / 60); - + if(tmp_minutes) { tmp_seconds -= (tmp_minutes * 60); tmp_hours = floor(tmp_minutes / 60); - + if(tmp_hours) { tmp_minutes -= (tmp_hours * 60); tmp_days = floor(tmp_hours / 24); - + if(tmp_days) { tmp_hours -= (tmp_days * 24); tmp_weeks = floor(tmp_days / 7); - + if(tmp_weeks) { tmp_days -= (tmp_weeks * 7); @@ -192,6 +192,24 @@ string process_time(float outputtype, float seconds) ((output != "") ? sprintf(", %s", output) : "")); } + return output; + } + case 3: + { + string output = ""; + + output = count_hours(tmp_hours); + + if(tmp_weeks) { tmp_days += (tmp_weeks * 7); } + if(tmp_years) { tmp_days += (tmp_years * 365); } + if(tmp_days) + { + output = sprintf( + "%s%s", + count_days(tmp_days), + ((output != "") ? sprintf(", %s", output) : "")); + } + return output; } }