Search code examples
getstream-io

Using different time zones for strftime in aggregated feeds


If I understand correctly, if I'm attempting to aggregate activities in an aggregated feed group based on their calendar day, I necessarily do this relative to the UTC date. This unfortunately can yield confusing results if it's done somewhere like North America. Is it possible to aggregate on a date relative to a different time zone? Is there another way to achieve a similar result?


Solution

  • Currently it's not possible to provide an offset to the strftime function inside of an aggregation rule.

    Without knowing all the specifics I think you may be able to achieve the desired result by adding a separate custom field such as local_date (e.g. with a string value of '2018-05-15'). This would be pre-computed and included with the Activity when it's added to a Stream feed, and referred to in the aggregation rule like {{ local_date }}.

    The cavieat / limitation is that you'll need to decide whether to use the 'local date' from the perspective of a user who creates an activity (which may be different to the user reading a feed containing the activity), or a system-wide date that's applied across the application regardless of where your user's are located.