There's already a bunch of apps afaik, even ones that take melatonin and caffeine into account.
Thank. Will look into it.