FifiTheBulldog

Scriptable Save Last Run Time to Keychain Example

Apr 2nd, 2022
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const key = Script.name() + " last run";
  2.  
  3. /**/
  4. if (Keychain.contains(key)) {
  5.   const lastRunMs = Number(Keychain.get(key));
  6.   const lastRun = new Date(lastRunMs);
  7.   log("Last run: " + lastRun.toString());
  8. } else {
  9.   log("Script has not been run yet");
  10. }
  11.  
  12. const now = String(Date.now());
  13. Keychain.set(key, now);
  14. log("Saved last run date");
  15.  
  16. /**
  17. Keychain.remove(key);
  18. log("Removed key from keychain")
  19. /**/
Advertisement
Add Comment
Please, Sign In to add comment