Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweet "date" information #10

Closed
gapmiss opened this issue Aug 16, 2022 · 2 comments
Closed

Tweet "date" information #10

gapmiss opened this issue Aug 16, 2022 · 2 comments

Comments

@gapmiss
Copy link

gapmiss commented Aug 16, 2022

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
Copy link
Author

gapmiss commented Aug 16, 2022

before:

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

after:

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

@kbravh
Copy link
Owner

kbravh commented Oct 25, 2022

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: #17

@kbravh kbravh closed this as completed Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants