From 1a7538265f7a2748e8864c002e75e55cb8a270ba Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 27 Jul 2018 08:27:37 +0200 Subject: lib/converter.php -> lib/helper.php --- lib/helper.php | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 lib/helper.php (limited to 'lib/helper.php') diff --git a/lib/helper.php b/lib/helper.php new file mode 100644 index 0000000..41951c7 --- /dev/null +++ b/lib/helper.php @@ -0,0 +1,86 @@ + 1) + $result = + sprintf( + "%d days and %s", + $tmp, + $result + ); + elseif ($tmp == 1) + $result = + sprintf( + "%d day and %s", + $tmp, + $result + ); + else + $printed_conjunction = false; + $val = floor($val / 7); + if ($val == 0) + return $result; + if ($printed_conjunction) + $result = + sprintf( + ", %s", + $result + ); + else + $result = + sprintf( + " and %s", + $result + ); + if ($val>1) + $result = + sprintf( + "%d weeks%s", + $val, + $result + ); + else + $result = + sprintf( + "%d week%s", + $val, + $result + ); + return $result; +} -- cgit v1.2.3