Flowframe / laravel-trend

Generate trends for your models. Easily generate charts or reports.
MIT License
607 stars 64 forks source link

Timezone support #23

Closed bohemianoid closed 1 year ago

bohemianoid commented 1 year ago

The method convertTimezone adds the ability to aggregate in a different timezone than the timezone of the database (closes #19):

$trend = Trend::model(...)
    ->between(...)
    ->perMonth()
    ->convertTimezone(
        from: 'UTC',
        to: 'Europe/Amsterdam',
    )
    ->count();

Unfortunately, I couldn't find a way to convert the timezone for SQLite and therefore implemented an error message in that case. Additionally, I wasn't able to test these changes in pgSQL. Could please somebody verify the changes on a pgSQL database?

iAmKevinMcKee commented 1 year ago

I would love to see this merged. Do you have any plans to merge this?

Larsklopstra commented 1 year ago

All adapters should have the same features, SQLite not supporting it seems like a deal breaker to me...