From 88abc56ea3b3a113552dceed1479ac0c4bfa305c Mon Sep 17 00:00:00 2001 From: Michael Spencer Date: Sat, 10 Jan 2015 22:16:51 -0600 Subject: [PATCH] Add a function for getting a number's ordinal --- modules/Material/Extras/js/utils.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/Material/Extras/js/utils.js b/modules/Material/Extras/js/utils.js index 51857d6..7a701b0 100644 --- a/modules/Material/Extras/js/utils.js +++ b/modules/Material/Extras/js/utils.js @@ -110,7 +110,20 @@ function newObject(path, args, parent) { if (component.status === QtQuick.Component.Error) { // Error Handling print("Unable to load object: " + path + "\n" + component.errorString()) + return null } return component.createObject(parent, args); } + +function nth(d) { + if(d>3 && d<21) + return 'th'; // thanks kennebec + + switch (d % 10) { + case 1: return "st"; + case 2: return "nd"; + case 3: return "rd"; + default: return "th"; + } +}