Skip to content

Instantly share code, notes, and snippets.

@theophani
Created November 6, 2012 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theophani/4026580 to your computer and use it in GitHub Desktop.
Save theophani/4026580 to your computer and use it in GitHub Desktop.
Untitled
Drag this link into your
bookmark bar:
<a href='javascript: function () { var field = document.querySelector("#promotion_days"); function days(date) { var parts = date.split("-"); // YY-MM-DD var year = parseInt(parts[0]) + 2000; var month = parseInt(parts[1]) - 1; var day = parseInt(parts[2]); console.log(year, month, day); var now = new Date(); var then = new Date(year, month, day, 0,0,0,0); var days = Math.ceil((then - now) / 1000 / 3600 / 24); return days; } var date = prompt("When should this gift expire? Tell me in YY-MM-DD format!"); field.value = days(date);}'>Gift Expiry</a>
<br>
<br>
Then while looking at a gift form, click the bookmarklet :)
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"html"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment