lucasvtiradentes / gcal-sync

🔄 add an one way synchronization from ticktick/github to google calendar and track your progress effortlessly.
https://www.npmjs.com/package/gcal-sync
MIT License
47 stars 3 forks source link

timeZoneCorrection seems to be ignored? #99

Closed StephenCoady closed 1 year ago

StephenCoady commented 1 year ago

I'm not 100% but I think the above variable timeZoneCorrection isn't taken into account for me.

I've set it to 1, +1 and '1', -3, but nothing seems to make a difference and the events are always 4 hours ahead of what ticktick knows about.

Am I doing something wrong or do I need to set something elsewhere also? Thanks.

lucasvtiradentes commented 1 year ago

Hello, StephenCoady

it should've worked if you set the value as number, that would be -4 or 4, without quotes.

please try it again and report it here.


I actually noticed some strange bugs since my last update, maybe google calendar/github api have changed and I still don't know. anyway I'm going to fix some of these issues next sartuday.

StephenCoady commented 1 year ago

just tried that and still the same. I'm UTC + 1 but it seems to be stuck on UTC -3 for me.

thanks, great application by the way - thanks for working on it.

StephenCoady commented 1 year ago

I had an (admittedly quick) look through the code, is this bug by any chance related to these two lines? there seems to be some hardcoding of UTC-3? Happy to send a PR if so. If that is the bug, is there a need for the timezone adjustment at all, since it seems to use the tzdata from ticktick?

https://github.com/lucasvtiradentes/gcal-sync/blob/master/src/GcalSync.ts#L321

https://github.com/lucasvtiradentes/gcal-sync/blob/master/src/GcalSync.ts#L325

lucasvtiradentes commented 1 year ago

I had an (admittedly quick) look through the code, is this bug by any chance related to these two lines? there seems to be some hardcoding of UTC-3? Happy to send a PR if so. If that is the bug, is there a need for the timezone adjustment at all, since it seems to use the tzdata from ticktick?

https://github.com/lucasvtiradentes/gcal-sync/blob/master/src/GcalSync.ts#L321

https://github.com/lucasvtiradentes/gcal-sync/blob/master/src/GcalSync.ts#L325

Man, probably those lines are the root of the problem.

I forgot to implement the timezones correction there.

Great catch by the away.

StephenCoady commented 1 year ago

No problem, happy to help. If it is not a big fix for you to do I'll stay away from a PR in case I cause more damage than I fix :)

Thanks.

lucasvtiradentes commented 1 year ago

Hi, I've just shipped a new version, I tested it here and it worked correctly.

Please, try again, but first update the gcal-sync version on your google apps script project to the latest:

const version = "1.7.8"

My 20 minutes fix was creating a handler function:

const getTimeZoneFixedString = (fixer: number) => {
  if (fixer === 0) {
    return '';
  }
  return `${fixer < 0 ? '-' : '+'}${String(Math.abs(fixer)).padStart(2, '0')}:00`;
};
const timezoneFixedString = getTimeZoneFixedString(this.config.datetime.timeZoneCorrection);

It worked for my current timezone correction (-3),

please, try it for yours (probably 1, right?) and also for 0

and report here if any further work is necessary.


feel free to suggest new features and other bugs, this project helps me so much, I'm really proud of this simple tool.

StephenCoady commented 1 year ago

That works, thank you so much.