tweet-to-markdown
tweet-to-markdown copied to clipboard
Tweet "date" information
I noticed that tweet-to-markdown does not have the "date" information, which the Obsidian plugin has.
I edited the main.js
directly. Here is the diff
for anyone that might find this useful or if someone wants to upgrade the source code to add this feature.
17808c17808
< 'tweet.fields': 'attachments,public_metrics,entities,conversation_id,referenced_tweets',
---
> 'tweet.fields': 'attachments,public_metrics,entities,conversation_id,referenced_tweets,created_at',
18042a18043,18045
> // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
> // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat
> const cdate_options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour12: true,hour: 'numeric', minute: 'numeric', timeZone: 'America/Los_Angeles', timeZoneName: 'short' };
18043a18047,18048
> let created = new Date(tweet.data.created_at);
> let fetched = new Date();
18045a18051,18052
> `date: ${created.toLocaleDateString('en-US', cdate_options)}`, // Tue, Aug 16, 2022, 2:41 PM PDT
> `fetched: ${fetched.toLocaleDateString('en-US', cdate_options)}`,
18089a18097
> const date_options = { year: 'numeric', month: 'short', day: 'numeric' };
18095c18103
< `${user.name} ([@${user.username}](https://twitter.com/${user.username}))`, // name and handle
---
> `${user.name} ([@${user.username}](https://twitter.com/${user.username})) - ${created.toLocaleDateString('en-US', date_options)}`, // name, handle and date (Aug 10, 2022)
before:
after:
I've just published version 2.4.0, which now includes the date of the tweet in the generated markdown. There's still some work to do to allow users to define their own formats, which I will follow here: https://github.com/kbravh/tweet-to-markdown/issues/17