Skip to content

Commit

Permalink
Add a function for getting a number's ordinal
Browse files Browse the repository at this point in the history
  • Loading branch information
iBelieve committed Jan 11, 2015
1 parent d82ce86 commit 88abc56
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions modules/Material/Extras/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

0 comments on commit 88abc56

Please sign in to comment.