File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 28
28
#include " hermes/VM/JSArray.h"
29
29
#include " hermes/VM/JSArrayBuffer.h"
30
30
#include " hermes/VM/JSLib.h"
31
+ #include " hermes/VM/JSLib/JSLibStorage.h"
31
32
#include " hermes/VM/JSLib/RuntimeJSONUtils.h"
32
33
#include " hermes/VM/NativeState.h"
33
34
#include " hermes/VM/Operations.h"
@@ -1070,6 +1071,7 @@ class HermesRuntimeImpl final : public HermesRuntime,
1070
1071
1071
1072
// / Concrete declarations of HermesRuntime methods.
1072
1073
void sampledTraceToStreamInDevToolsFormat (std::ostream &stream) override ;
1074
+ void resetTimezoneCache () override ;
1073
1075
sampling_profiler::Profile dumpSampledTraceToProfile () override ;
1074
1076
void loadSegment (
1075
1077
std::unique_ptr<const jsi::Buffer> buffer,
@@ -1285,6 +1287,10 @@ class BufferAdapter final : public ::hermes::Buffer {
1285
1287
};
1286
1288
} // namespace
1287
1289
1290
+ void HermesRuntimeImpl::resetTimezoneCache () {
1291
+ runtime_.getJSLibStorage ()->localTimeOffsetCache .reset ();
1292
+ }
1293
+
1288
1294
void HermesRuntimeImpl::loadSegment (
1289
1295
std::unique_ptr<const jsi::Buffer> buffer,
1290
1296
const jsi::Value &context) {
Original file line number Diff line number Diff line change @@ -122,11 +122,16 @@ class HERMES_EXPORT HermesRuntime : public jsi::Runtime {
122
122
// / be used by third parties.
123
123
virtual sampling_profiler::Profile dumpSampledTraceToProfile () = 0;
124
124
125
- // The base class declares most of the interesting methods. This
126
- // just declares new methods which are specific to HermesRuntime.
127
- // The actual implementations of the pure virtual methods are
128
- // provided by a class internal to the .cpp file, which is created
129
- // by the factory.
125
+ // / Resets the timezone offset cache used by Hermes for performance
126
+ // / optimization. Hermes maintains a cached timezone offset to accelerate date
127
+ // / and time calculations. However, this cache does not automatically detect
128
+ // / changes to the system timezone. When the system timezone changes, the
129
+ // / integration layer (e.g., React Native) must call this method to invalidate
130
+ // / the cache and ensure correct time calculations.
131
+ // /
132
+ // / \note Call this method immediately after detecting any timezone change in
133
+ // / the integrator.
134
+ virtual void resetTimezoneCache () = 0;
130
135
131
136
// / Load a new segment into the Runtime.
132
137
// / The \param context must be a valid RequireContext retrieved from JS
Original file line number Diff line number Diff line change @@ -98,6 +98,12 @@ TEST_P(HermesRuntimeTest, StrictHostFunctionBindTest) {
98
98
.getBool ());
99
99
}
100
100
101
+ TEST_P (HermesRuntimeTest, ResetTimezoneCache) {
102
+ if (auto *hrt = castInterface<IHermes>(rt.get ())) {
103
+ EXPECT_NO_THROW ({ hrt->resetTimezoneCache (); });
104
+ }
105
+ }
106
+
101
107
TEST_P (HermesRuntimeTest, DescriptionTest) {
102
108
// Minimally, if the description doesn't include "Hermes", something
103
109
// is wrong.
You can’t perform that action at this time.
0 commit comments