ShareShortcuts

Business Days Until Date

rasmus-lo
Fork “Business Days Until Date”

Built something new on top of this Shortcut? Share it as a fork: it becomes a Shortcut of your own, which you manage, and both pages link to each other so rasmus-lo gets credit.

  1. 1Get the Shortcut and change it in the Shortcuts app. Give it a name of its own.
  2. 2Share it from the Shortcuts app and copy the iCloud link.
  3. 3Come back here, paste the link and describe what is different, e.g. “Added a step that uses Apple Intelligence to personalise the text.”
Downloads
73K
Saved
0
Actions
24
Category
API
Version
1.0
Language
EN

WolframAlpha - # of business days until a future date

Return the number of business days from now until a future date


The shortcut calculates the number of working days until a future date using the WolframAlpha API.

You'll first need to sign up for your own API key before installing the shortcut:

https://products.wolframalpha.com/api/

What's New

Version 1.0

First release

Version History
1.0 Nov 4, 2018

First release

What it does

24 actions
  1. Text
  2. Comment
    You will need to sign up for your personal API key at https://products.wolframalpha.com/api/ Enter your API key below:
  3. Text
  4. Set Variable
    api_key
  5. Text
  6. Set Variable
    jsonpath_query
  7. Ask for Input
    What is the future date?
  8. Format Date
  9. Set Variable
    date
  10. Text
  11. URL Encode
  12. Text
  13. Get Contents of URL
  14. Get Text from Input
  15. Set Variable
    json_result
  16. Text
  17. Set Variable
    jsonpath_script
  18. Text
  19. Base64 Encode
  20. URL
    data:text/html;base64,…
  21. Get Contents of Web Page
  22. Get Text from Input
  23. Set Variable
    result
  24. Show Result

View as code
Beta

Every action of this Shortcut written out as Cherri, a programming language for Shortcuts. Great for learning how it works.

#include 'actions/web'
#include 'actions/calendar'
#define color red
#define glyph calendar

/*
You will need to sign up for your personal API key at https://products.wolframalpha.com/api/

Enter your API key below:
*/
@api_key = "nil"
@jsonpath_query = "$..pods[?(@.scanner == 'Identity')].subpods[?(@.primary == true)].plaintext"
prompt("What is the future date?", "Date")
formatTimestamp("", "Long", "None")
@date = nil
urlEncode("")
downloadURL("")
getText(nil)
@json_result = nil
@jsonpath_script = "/* JSONPath 0.8.0 - XPath for JSON\n *\n * Copyright (c) 2007 Stefan Goessner (goessner.net)\n * Licensed under the MIT (MIT-LICENSE.txt) licence.\n */\nfunction jsonPath(obj, expr, arg) {\n   var P = {\n      resultType: arg && arg.resultType || \\"VALUE\\",\n      result: [],\n      normalize: function(expr) {\n         var subx = [];\n         return expr.replace(/[\['](\??\(.*?\))[\]']/g, function($0,$1){return \\"[#\\"+(subx.push($1)-1)+\\"]\\";})\n                    .replace(/'?\.'?|\['?/g, \\";\\")\n                    .replace(/;;;|;;/g, \\";..;\\")\n                    .replace(/;$|'?\]|'$/g, \\"\\")\n                    .replace(/#([0-9]+)/g, function($0,$1){return subx[$1];});\n      },\n      asPath: function(path) {\n         var x = path.split(\\";\\"), p = \\"$\\";\n         for (var i=1,n=x.length; i<n; i++)\n            p += /^[0-9*]+$/.test(x[i]) ? (\\"[\\"+x[i]+\\"]\\") : (\\"['\\"+x[i]+\\"']\\");\n         return p;\n      },\n      store: function(p, v) {\n         if (p) P.result[P.result.length] = P.resultType == \\"PATH\\" ? P.asPath(p) : v;\n         return !!p;\n      },\n      trace: function(expr, val, path) {\n         if (expr) {\n            var x = expr.split(\\";\\"), loc = x.shift();\n            x = x.join(\\";\\");\n            if (val && val.hasOwnProperty(loc))\n               P.trace(x, val[loc], path + \\";\\" + loc);\n            else if (loc === \\"*\\")\n               P.walk(loc, x, val, path, function(m,l,x,v,p) { P.trace(m+\\";\\"+x,v,p); });\n            else if (loc === \\"..\\") {\n               P.trace(x, val, path);\n               P.walk(loc, x, val, path, function(m,l,x,v,p) { typeof v[m] === \\"object\\" && P.trace(\\"..;\\"+x,v[m],p+\\";\\"+m); });\n            }\n            else if (/,/.test(loc)) { // [name1,name2,...]\n               for (var s=loc.split(/'?,'?/),i=0,n=s.length; i<n; i++)\n                  P.trace(s[i]+\\";\\"+x, val, path);\n            }\n            else if (/^\(.*?\)$/.test(loc)) // [(expr)]\n               P.trace(P.eval(loc, val, path.substr(path.lastIndexOf(\\";\\")+1))+\\";\\"+x, val, path);\n            else if (/^\?\(.*?\)$/.test(loc)) // [?(expr)]\n               P.walk(loc, x, val, path, function(m,l,x,v,p) { if (P.eval(l.replace(/^\?\((.*?)\)$/,\\"$1\\"),v[m],m)) P.trace(m+\\";\\"+x,v,p); });\n            else if (/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(loc)) // [start:end:step]  phyton slice syntax\n               P.slice(loc, x, val, path);\n         }\n         else\n            P.store(path, val);\n      },\n      walk: function(loc, expr, val, path, f) {\n         if (val instanceof Array) {\n            for (var i=0,n=val.length; i<n; i++)\n               if (i in val)\n                  f(i,loc,expr,val,path);\n         }\n         else if (typeof val === \\"object\\") {\n            for (var m in val)\n               if (val.hasOwnProperty(m))\n                  f(m,loc,expr,val,path);\n         }\n      },\n      slice: function(loc, expr, val, path) {\n         if (val instanceof Array) {\n            var len=val.length, start=0, end=len, step=1;\n            loc.replace(/^(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)$/g, function($0,$1,$2,$3){start=parseInt($1||start);end=parseInt($2||end);step=parseInt($3||step);});\n            start = (start < 0) ? Math.max(0,start+len) : Math.min(len,start);\n            end   = (end < 0)   ? Math.max(0,end+len)   : Math.min(len,end);\n            for (var i=start; i<end; i+=step)\n               P.trace(i+\\";\\"+expr, val, path);\n         }\n      },\n      eval: function(x, _v, _vname) {\n         try { return $ && _v && eval(x.replace(/@/g, \\"_v\\")); }\n         catch(e) { throw new SyntaxError(\\"jsonPath: \\" + e.message + \\": \\" + x.replace(/@/g, \\"_v\\").replace(/\^/g, \\"_a\\")); }\n      }\n   };\n\n   var $ = obj;\n   if (expr && obj && (P.resultType == \\"VALUE\\" || P.resultType == \\"PATH\\")) {\n      P.trace(P.normalize(expr).replace(/^\$;/,\\"\\"), obj, \\"$\\");\n      return P.result.length ? P.result : false;\n   }\n} "
base64Encode(nil)
url("data:text/html;base64,{}")
getWebpageContents("")
getText(nil)
@result = nil
show("There are {@result} until {@date}")
Open in Cherri Playground Decompiled with cherri 2.3.0 (GPL-2.0). May need small fixes before it compiles.

Ratings & Reviews

Write a Review
–
out of 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Advertisement

More by rasmus-lo

See All

You Might Also Like

See All
Advertisement