1. 事象
ownCloudのカレンダーでタイムゾーンがうまく認識されず表示がおかしくなる。
「タイムゾーン[Etc/GMT-9]が不明なため、代わりにUTCを使用します。」
正しく表示された場合は以下のようになる。
2. 環境
ownCloud : 10.8.0
– calender : 1.6.4
クライアント(再現を確認したもの)
Google Chrone : 92.0.4515.131(Windows)
Firefox : 91.0(Windows)
※LinuxのGoogle Chromeでは発生しない
3. 解決策
すでに参考に挙げたリンク先で議論されており、パッチも存在していた。ブラウザ側のバグだとも考えられるが、一向に修正される気配がないのでパッチを適用することにした。
【参考】
https://github.com/clear-code/statistics/issues/189
https://github.com/nextcloud/calendar/issues/496#issuecomment-326791894
3-1. 修正方針
パッチを適用してビルドしたファイルのうち問題箇所の「TimezoneService」が定義されている以下の3ファイルを置き換える。
OC/apps/calendar/js/public
・app.js
・app.min.js
・app.min.js.map
3-2. 修正手順
3-2-1. カレンダーアプリのコードを取得
git clone https://github.com/owncloud/calendar.git
3-2-2. パッチを適用する
クローンしたカレンダーのディレクトリに移動して以下の差分を参考に修正する。
$ git diff diff --git a/js/app/service/timezoneService.js b/js/app/service/timezoneService.js index 3c90ed0e..d5d7f371 100644 --- a/js/app/service/timezoneService.js +++ b/js/app/service/timezoneService.js @@ -43,7 +43,10 @@ app.service('TimezoneService', function (TimezoneDataProvider, Timezone) { * @returns {string} */ this.current = function () { + const dateTimeFormat = Intl.DateTimeFormat; + Intl.DateTimeFormat = function() {return {resolvedOptions: function() {return {};}};}; const tz = jstz.determine(); + Intl.DateTimeFormat = dateTimeFormat; let tzname = tz ? tz.name() : 'UTC'; if (TimezoneDataProvider.aliases[tzname]) {
以下を参考にしています。
https://github.com/Hakuyume/nextcloud-calendar/commit/ea1c314e6c4e925d440a64d2ca0d52d9a18812e2
3-2-3. ビルド
makeではうまくいかなく、原因探すのがめんどくさかったので手動でコマンドを実行した。
$ npm install yarn $ npm run build
3-2-4. 配置
ビルドが成功すると以下のファイルが出来ているのでこれを取得しサーバのファイルを置換する。
./js/public
・app.js
・app.min.js
・app.min.js.map
4. 修正結果確認
正しく表示されるようになった。
以上