Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2015 07:01
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 anonymous/0373011a1236483b7ec9 to your computer and use it in GitHub Desktop.
Save anonymous/0373011a1236483b7ec9 to your computer and use it in GitHub Desktop.
var next_story;
var next_day;
function gochiusa(year, month, day) {
now = new Date();
start = new Date(year, month - 1, day);
msec = now.getTime() - start.getTime();
next_story = Math.floor((msec / (1000 * 60 * 60 * 24) - 1) / 7) + 2;
// まだ放映開始前の場合は、羽数を第1羽にして、放送日は開始日にする
if (next_story < 1) {
next_story = 1;
next_day = start;
} else {
next = start.getTime() + (next_story - 1) * 7 * (1000 * 60 * 60 * 24);
next_day = new Date();
next_day.setTime(next);
}
document.write('第' + next_story + '羽 (' + next_day.getFullYear() + '/' + (next_day.getMonth() + 1) + '/' + next_day.getDate() + ')');
}
function gochiusa_twitter(title, url) {
str = '次回の' + title + 'は第' + next_story + '羽(' + (next_day.getMonth() + 1) + '月' + next_day.getDate() + '日)です。 @Naba0123 さんから';
uri_str = encodeURI(str);
document.write('<a href="https://twitter.com/intent/tweet?button_hashtag=gochiusa&text=' + uri_str + '" class="twitter-hashtag-button" data-size="large" data-url="http://app.naba.biz/' + url + '/">#gochiusa をつぶやく</a>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment