tweet-to-markdown icon indicating copy to clipboard operation
tweet-to-markdown copied to clipboard

Tweet "date" information

Open gapmiss opened this issue 1 year ago • 1 comments

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)

gapmiss avatar Aug 16 '22 23:08 gapmiss

before:

Screenshot 2022-08-16 at 22-51-41 ttm obsmd io

after:

Screenshot 2022-08-16 at 22-53-49 ttm obsmd io

gapmiss avatar Aug 16 '22 23:08 gapmiss

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

kbravh avatar Oct 25 '22 17:10 kbravh