-
-
Save hyuki/ab36070fae8d34d1cb9341b7b5a8f950 to your computer and use it in GitHub Desktop.
#ChatGPT と結城浩が共同で作ったコード(IFTTT ProでTwitterへのツイートをEvernoteのノートに保存するときに使うフィルタ)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // TypeScript v2.92 | |
| function padLeft(str: string, targetLength: number, padChar: string): string { | |
| const padding = targetLength - str.length; | |
| if (padding <= 0) { | |
| return str; | |
| } | |
| return repeatString(padChar, padding) + str; | |
| } | |
| function repeatString(str: string, count: number): string { | |
| let repeated = ''; | |
| for (let i = 0; i < count; i++) { | |
| repeated += str; | |
| } | |
| return repeated; | |
| } | |
| function formatDate(input: string): string { | |
| const months = { | |
| January: '01', | |
| February: '02', | |
| March: '03', | |
| April: '04', | |
| May: '05', | |
| June: '06', | |
| July: '07', | |
| August: '08', | |
| September: '09', | |
| October: '10', | |
| November: '11', | |
| December: '12', | |
| }; | |
| const datePattern = /(\w+)\s(\d+),\s(\d{4})/; | |
| const match = input.match(datePattern); | |
| if (match) { | |
| const month = months[match[1] as keyof typeof months]; | |
| const day = padLeft(match[2], 2, '0'); | |
| const year = match[3]; | |
| return `${year}-${month}-${day}`; | |
| } | |
| throw new Error('Invalid date format'); | |
| } | |
| const tweet_date = formatDate(Twitter.newTweetByYou.CreatedAt); | |
| const note_title = `My Tweet ${tweet_date}`; | |
| Evernote.appendToNote.setTitle(note_title); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://twitter.com/hyuki/status/1644966058833625094