Skip to content

[6.x] Improved Timezone Handling #11409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 119 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from 118 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
102942e
Add failing test for the update script
duncanmcclean Jan 28, 2025
616c92d
Implement update script
duncanmcclean Jan 28, 2025
d8452be
Support nested fields in UTC update script
duncanmcclean Jan 30, 2025
bee4d65
Ensure fields inside fieldsets are handled properly
duncanmcclean Jan 30, 2025
2b61ad8
Use data provider in tests
duncanmcclean Jan 30, 2025
e8cb35f
Remove condition I added for troubleshooting
duncanmcclean Jan 30, 2025
d7d2595
Bail out early when the app's timezone is already UTC
duncanmcclean Jan 30, 2025
a92bc0f
Ensure entry date field is updated correctly.
duncanmcclean Jan 30, 2025
cd82107
wip
duncanmcclean Jan 30, 2025
a403b8a
Add test to cover updating users too
duncanmcclean Jan 30, 2025
69d0d39
Add tests for terms & globals too
duncanmcclean Jan 31, 2025
d320852
Ensure entry dates are converted to UTC before saving
duncanmcclean Jan 31, 2025
a133e51
Augment dates using `display_timezone` config
duncanmcclean Jan 31, 2025
0cab171
Ensure `now` cascade variable uses the display timezone
duncanmcclean Jan 31, 2025
8a0ea55
`Entry::date()` handles the conversion, so we don't need to handle it…
duncanmcclean Jan 31, 2025
8d88ddf
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Feb 6, 2025
baff33d
Ensure GraphQL always returns dates in UTC.
duncanmcclean Feb 6, 2025
f34c61d
Revert "Ensure `now` cascade variable uses the display timezone"
duncanmcclean Feb 11, 2025
74893d6
Revert "Augment dates using `display_timezone` config"
duncanmcclean Feb 11, 2025
db7cc90
UTC forever
duncanmcclean Feb 11, 2025
6343017
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Feb 11, 2025
33e0380
wip
duncanmcclean Feb 13, 2025
8121d27
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Feb 13, 2025
0d0cd6a
Update script should save the time for "date-only" fields
duncanmcclean Feb 14, 2025
ed7f02a
We should always be saving the time alongside dates.
duncanmcclean Feb 14, 2025
a1f3f7d
wip
duncanmcclean Feb 14, 2025
2395e40
wip
duncanmcclean Feb 14, 2025
8093b09
wip
duncanmcclean Feb 17, 2025
f5b7f29
wip
duncanmcclean Feb 17, 2025
6b96883
wip
duncanmcclean Feb 17, 2025
27db3f9
Use a forked version of `v-calendar` for now
duncanmcclean Feb 17, 2025
e9eba1e
Add JS tests for the Date fieldtype
duncanmcclean Feb 17, 2025
26c9fdf
Replicator preview should use local time.
duncanmcclean Feb 17, 2025
454f073
Handle the empty state.
duncanmcclean Feb 17, 2025
caa9e38
Handle `date_field: now`
duncanmcclean Feb 17, 2025
0a6485f
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Feb 18, 2025
a9c1601
Support date ranges
duncanmcclean Feb 18, 2025
fb01da6
Update date fieldtype tests.
duncanmcclean Feb 18, 2025
71f3af0
Refactor date range defaults.
duncanmcclean Feb 18, 2025
dc087c7
wip
duncanmcclean Feb 18, 2025
927c9c5
Handle range value being a string.
duncanmcclean Feb 18, 2025
b1fd1b3
It could be an integer. Account for that too.
duncanmcclean Feb 18, 2025
2f4318f
wip
duncanmcclean Feb 18, 2025
52a542f
We're handling this on the Vue side now. Move tests.
duncanmcclean Feb 18, 2025
360dd0c
wip
duncanmcclean Feb 19, 2025
8e416b5
Fix JS tests when running in a different timezone.
duncanmcclean Feb 19, 2025
9402a40
Prettier.
duncanmcclean Feb 19, 2025
013087a
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Feb 19, 2025
b5041be
Localize dates in listings.
duncanmcclean Feb 19, 2025
c5e9103
Prettier.
duncanmcclean Feb 19, 2025
e547f08
Run the update script even when the app's timezone is UTC
duncanmcclean Feb 19, 2025
d1bcb90
Fix update script test
duncanmcclean Feb 19, 2025
568ebc2
Time should always be included in entry filenames.
duncanmcclean Feb 19, 2025
4e6e003
Set timezone here too.
duncanmcclean Feb 19, 2025
2f98d52
Fix Stache tests which rely on the entry date prefix in filenames.
duncanmcclean Feb 20, 2025
7d1380f
Update entry fixtures to fix entry repo tests.
duncanmcclean Feb 20, 2025
2fb8a1b
wip
duncanmcclean Feb 20, 2025
7b57048
Simplify.
duncanmcclean Feb 20, 2025
0611396
Ensure `Entry::date()` always returns UTC Carbon instances
duncanmcclean Feb 20, 2025
77828a3
Fix update script for entry date fields.
duncanmcclean Feb 20, 2025
1459821
This test isn't needed anymore.
duncanmcclean Feb 20, 2025
a139181
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Feb 27, 2025
9a029f7
Fix entry scheduling when app timezone isn't UTC
duncanmcclean Feb 27, 2025
c278f51
Don't strip out the time from entry date field
duncanmcclean Feb 27, 2025
a814250
When the item has dirty state, only save when something has changed.
duncanmcclean Feb 27, 2025
653c2a8
Show a progress bar during the update script.
duncanmcclean Feb 27, 2025
77f56b5
Always include the time when augmenting date fields..
duncanmcclean Feb 28, 2025
3bed970
Convert dates on the frontend to the site's display timezone.
duncanmcclean Feb 28, 2025
960457a
Alias `timezone` modifier to `tz`
duncanmcclean Feb 28, 2025
ff3691e
Timezone modifier should fallback to the display timezone, rather tha…
duncanmcclean Feb 28, 2025
4445e8c
Collection route should use converted date
duncanmcclean Feb 28, 2025
b99c96d
Add tests for some of the date modifiers
duncanmcclean Feb 28, 2025
4dc546f
Add `display_timezone` option to config
duncanmcclean Feb 28, 2025
f66bcf0
Add `statamic.system.localize_dates_in_modifiers` config option
duncanmcclean Feb 28, 2025
8b4d2f1
Restore carbon locale when tearing down test
duncanmcclean Feb 28, 2025
ed6be78
When adding a date, time should be "00:00"
duncanmcclean Mar 3, 2025
9100c5a
Fix augmentation test.
duncanmcclean Mar 3, 2025
071a80e
Prettier
duncanmcclean Mar 3, 2025
793761d
Update system.php config during update script
duncanmcclean Mar 3, 2025
531d46b
tz is already an alias of the timezone modifier
duncanmcclean Mar 4, 2025
67fc4ca
Sometimes, it might be a closure.
duncanmcclean Mar 4, 2025
0369c21
Make `Statamic::displayTimezone()` method so it'll fallback to app ti…
duncanmcclean Mar 4, 2025
f196c67
We don't want to convert dates during upgrade anymore.
duncanmcclean Mar 4, 2025
f037f50
Dates should be saved in the app timezone, but converted to UTC for t…
duncanmcclean Mar 4, 2025
37374f3
Call `Statamic::displayTimezone()` here too
duncanmcclean Mar 4, 2025
c53c318
This test doesn't actually need the timezone to change.
duncanmcclean Mar 4, 2025
b664921
We no longer store times with dates, so update the tests to reflect t…
duncanmcclean Mar 4, 2025
f8062ea
Fallback like this instead.
duncanmcclean Mar 4, 2025
bd4e5f3
Change assertion now we're storing in app timezone.
duncanmcclean Mar 5, 2025
1deebdd
Revert "We no longer store times with dates, so update the tests to r…
duncanmcclean Mar 5, 2025
5e08570
Remove UTC logic in the query builder
duncanmcclean Mar 5, 2025
a13a378
Time should be reset when selecting a new date and `time_enabled: false`
duncanmcclean Mar 5, 2025
0d2783e
whoops, didn't mean to commit these TODOs
duncanmcclean Mar 5, 2025
9f19f86
Use `->utc()` instead
duncanmcclean Mar 5, 2025
605a967
Entry date should be in app timezone before being preprocessed.
duncanmcclean Mar 5, 2025
d6e6340
Prettier
duncanmcclean Mar 5, 2025
2f67a08
We don't want seconds enabled for this test.
duncanmcclean Mar 5, 2025
1a1d2e1
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Mar 5, 2025
8651001
Test the timezone conversion process
duncanmcclean Mar 6, 2025
8fcb6d9
Merge remote-tracking branch 'origin/master' into utc-dates
duncanmcclean Mar 6, 2025
347a5d5
Save dates with time, even when time_enabled is false.
duncanmcclean Mar 6, 2025
e6ab7f2
Rename the upgrade script
duncanmcclean Mar 6, 2025
67a4805
We don't need this for the test.
duncanmcclean Mar 6, 2025
725a5a1
This change is unnecessary now.
duncanmcclean Mar 6, 2025
8521518
Default to null.
duncanmcclean Mar 6, 2025
ec44b1b
Bring back the migration script as a command.
duncanmcclean Mar 6, 2025
b09a085
Simplify.
duncanmcclean Mar 6, 2025
25e542d
Delete the user blueprint after running tests.
duncanmcclean Mar 6, 2025
9eb8f77
nitpick
jasonvarga Mar 6, 2025
0189bab
Revert force-addition of times in filenames. This'll be done conditio…
jasonvarga Mar 6, 2025
c39c257
Delete any blueprints and fieldsets added in this test as it causes f…
jasonvarga Mar 7, 2025
4f29c99
Dates in entry filenames will get times even if times arent configure…
jasonvarga Mar 10, 2025
a6b4489
Entry date when passed as a string is treated as utc.
jasonvarga Mar 10, 2025
6a58d30
Adjust test
jasonvarga Mar 11, 2025
d9e0a8c
Adjust implementation to handle the date method assuming utc
jasonvarga Mar 11, 2025
5ec4333
make a backup
jasonvarga Mar 11, 2025
b6499fd
update stub
jasonvarga Mar 11, 2025
8b757bc
Add more info
jasonvarga Mar 11, 2025
4ad616c
wip
jasonvarga Mar 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions config/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,35 @@

'date_format' => 'F jS, Y',

/*
|--------------------------------------------------------------------------
| Timezone
|--------------------------------------------------------------------------
|
| Statamic will use this timezone when displaying dates on the front-end.
| You can use any timezone supported by PHP. When set to null it will
| fall back to the timezone defined in your `app.php` config file.
|
| https://www.php.net/manual/en/timezones.php
|
*/

'display_timezone' => null,

/*
|--------------------------------------------------------------------------
| Localize Dates in Modifiers
|--------------------------------------------------------------------------
|
| When using date-related modifiers, Carbon instances will be in UTC.
| Enabling this setting will ensure that dates get localized into
| the timezone defined in `display_timezone`. Otherwise you'll
| need to manually localize dates in all of your templates.
|
*/

'localize_dates_in_modifiers' => false,

/*
|--------------------------------------------------------------------------
| Default Character Set
Expand Down
37 changes: 19 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"knip": "knip"
},
"dependencies": {
"@angelblanco/v-calendar": "^3.1.2",
"@floating-ui/dom": "^1.2.5",
"@he-tree/vue": "^2.8.2",
"@hoppscotch/vue-toasted": "^0.1.0",
Expand Down Expand Up @@ -85,7 +86,6 @@
"tiny-emitter": "^2.1.0",
"uniqid": "^5.2.0",
"upload": "^1.3.2",
"v-calendar": "^3.1.2",
"validator": "^13.7.0",
"vite-svg-loader": "^5.1.0",
"vue": "^3.4.27",
Expand Down
2 changes: 2 additions & 0 deletions resources/js/bootstrap/fieldtypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Routes from '../components/collections/Routes.vue';
import TitleFormats from '../components/collections/TitleFormats.vue';
import ColorFieldtype from '../components/fieldtypes/ColorFieldtype.vue';
import DateFieldtype from '../components/fieldtypes/DateFieldtype.vue';
import DateIndexFieldtype from '@/components/fieldtypes/DateIndexFieldtype.vue';
import DictionaryFieldtype from '../components/fieldtypes/DictionaryFieldtype.vue';
import DictionaryIndexFieldtype from '../components/fieldtypes/DictionaryIndexFieldtype.vue';
import DictionaryFields from '../components/fieldtypes/DictionaryFields.vue';
Expand Down Expand Up @@ -92,6 +93,7 @@ export default function registerFieldtypes(app) {
app.component('collection_title_formats-fieldtype', TitleFormats);
app.component('color-fieldtype', ColorFieldtype);
app.component('date-fieldtype', DateFieldtype);
app.component('date-fieldtype-index', DateIndexFieldtype);
app.component('dictionary-fieldtype', DictionaryFieldtype);
app.component('dictionary-fieldtype-index', DictionaryIndexFieldtype);
app.component('dictionary_fields-fieldtype', DictionaryFields);
Expand Down
4 changes: 2 additions & 2 deletions resources/js/bootstrap/statamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import useDirtyState from '../composables/dirty-state';
import VueClickAway from 'vue3-click-away';
import FloatingVue from 'floating-vue';
import 'floating-vue/dist/style.css';
import VCalendar from 'v-calendar';
import 'v-calendar/style.css';
import VCalendar from '@angelblanco/v-calendar';
import '@angelblanco/v-calendar/style.css';
import Toasts from '../components/Toasts';
import PortalVue from 'portal-vue';
import Keys from '../components/keys/Keys';
Expand Down
Loading