Elijas / auto-youtube-subscription-playlist-2

Script automatically adds videos to playlists from Youtube channels and/or subscriptions (Youtube Collections alternative).
MIT License
246 stars 54 forks source link

Compare dates instead of date strings #130

Closed Logicer16 closed 3 months ago

Logicer16 commented 4 months ago

The script may be configured to run with a timezone other than UTC. This means the strings cannot be compared until they are normalised to UTC as the same actual hour may otherwise be represented by different values.

For example:

// This:
item.snippet.publishedAt > lastTimestamp
// Becomes:
"2024-04-16T11:36:30Z" > "2024-04-16T21:23:36+10:00"
// Which is false even through the date on the left comes after the date on the right.

This incorrect comparison is done here: https://github.com/Elijas/auto-youtube-subscription-playlist-2/blob/25e6783932ef0ef4874422327fc0a6402ffac428/sheetScript.gs#L422 And here: https://github.com/Elijas/auto-youtube-subscription-playlist-2/blob/25e6783932ef0ef4874422327fc0a6402ffac428/sheetScript.gs#L526 Whereas a correct comparison is done here: https://github.com/Elijas/auto-youtube-subscription-playlist-2/blob/25e6783932ef0ef4874422327fc0a6402ffac428/sheetScript.gs#L378

victorjzsun commented 3 months ago

Thanks for the fix!