Repository navigation
Conversation
The flags service reads a date without a UTC offset and a relative date in the project's timezone, in the filter value and in the property value. Version 1 local evaluation read them in UTC. When the flag definitions give a timezone that resolves here, local evaluation now reads them as the service does: a bare date is midnight there, a date and time without an offset is a wall clock there, a relative date counts back on its wall clock, a repeated wall clock is its earlier instant and a skipped one matches nothing. A date or naive datetime property value is read as the ISO 8601 text a remote evaluation sends. Without a known timezone, the existing UTC reading is unchanged. The timezone reaches person, group, cohort and dependency conditions through an optional keyword next to property_matching_version.
SDK performance: posthog-pythonBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
Follow the local evaluator spec's date requirement for the project's timezone. A wall clock that a spring-forward transition skips, from parsing or from relative subtraction, makes the date condition inconclusive instead of a no-match, so the flag falls back. Every offset-free form the parser accepts is read in the project's timezone, not only the forms the flags service lists.
The gap check compared the offsets of the two folds, so a tzinfo that gives a wall clock in a gap one offset for either fold, such as dateutil's, read it as an instant. Detect the gap by converting the instant back to a wall clock instead. The filter check that runs when a property is missing parsed date filters in UTC, so a filter on a skipped wall clock reported missing_context. It now parses them in the project's timezone and reports unsupported_definition.
…cal-evaluation-project-timezone
…dispatch Choose between the UTC and the project-timezone date matching where the operator is dispatched, as the filter check already does, so the UTC function is the one on main. Take the current time in the timezone directly, pass the timezone to the filter check explicitly, and fold the inconclusive date tests into the table, which now also runs with dateutil's tzinfo and every unknown timezone form of the config version 2 tests.
💡 Motivation and Context
Stacked on #1328, which reads the project's
timezonefrom the flag definitions for config version 2 flags. This PR uses it for version 1 flags.The flags service reads a date without a UTC offset and a relative date in the project's timezone. It does so for the filter value and for the person or group property value (
parse_date_string_in_tzinrust/feature-flags/src/properties/property_matching.rs). Version 1 local evaluation reads them in UTC. So in a project on another timezone,is_date_before "2024-03-31"disagrees with the server around midnight, and a relative date such as-30ddisagrees for the length of the UTC offset.The sdk-specs requirement "Date criteria compare normalized instants in the effective timezone" (
local-feature-flag-evaluator) already says how this works. Date-only and naive values use the project's timezone when the evaluator has one, and UTC otherwise. This PR implements its timezone parts. When the timezone is unknown, nothing changes: dates are read in UTC as before, with no fallback.Details
unsupported_definition, also when the property is missing; a skipped property value givesmissing_context. (The service itself treats such a wall clock as no match.)tzinfo, including one that ignoresfold, such as dateutil's.dateanddatetimeproperty values. A remote evaluation sends them as ISO 8601 text (2024-03-31,2024-03-31T00:30:00), which the service reads in the project's timezone. So with a known timezone:dateis midnight there, compared as an instant (today it is compared by calendar day);datetimewithout a timezone is a wall clock there;datetimeis unchanged._match_date_propertykeeps its body.relative_date_parse_for_feature_flag_matchingnow calls a helper that takesnow; its behavior is the same.match_property,match_property_group,match_cohort,is_condition_match,match_feature_flag_propertiesandevaluate_flag_dependencygain an optionaltimezonekeyword next toproperty_matching_version, and the snapshot is updated. Person, group, cohort and dependency conditions all receive it, as on the server.is_date_exact;💚 How did you test it?
A new module,
posthog/test/test_local_evaluation_project_timezone.py. The existing date tests pass unchanged, and a differential run againstmaingave identical results with an unknown timezone.Details
match_property, each run in Europe/Oslo (withzoneinfoand with dateutil'stzinfo) and with an unknown timezone, with a fixed clock. They cover:dateanddatetimevalues;datetimein the same zone withfold=1;datetime, and reached by subtracting hours;is_date_beforeandis_date_afterstand in foris_date_exact.unsupported_definitionin Europe/Oslo andmissing_contextwithout a timezone, throughmatch_propertyand through the client.zoneinforejects) reads them in UTC, as before.main: 598 combinations of operator, filter value and property value, in time frozen across the DST change, gave identical results on this branch and onmain.dateread in UTC.ruff format --check .,ruff check ., mypy with the baseline,make public_api_check,python -W error -c "import posthog", and the full suite. Only the 3 fork tests intest_metrics_autocapture.pyfail, as they do onmainon macOS.📝 Checklist
If releasing new changes
sampo addto generate a changeset fileA
patchchangeset: version 1 local evaluation reads dates as the flags service does.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
main" checkable.ZoneInfoby wall clock and ignoresfold, which would be wrong on a repeated hour.🤖 Generated with Claude Code