@mcpcn/mcp-notification 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -174,11 +174,35 @@ class ReminderServer {
|
|
|
174
174
|
if (resp.code !== 0) {
|
|
175
175
|
return { content: [{ type: 'text', text: `设置失败:${resp.msg}` }], isError: true };
|
|
176
176
|
}
|
|
177
|
+
const triggerAt = resp.data?.triggerAt;
|
|
178
|
+
const offsetMin = typeof params.tzOffsetMin === 'number' ? params.tzOffsetMin : -new Date().getTimezoneOffset();
|
|
179
|
+
const formatOffset = (min) => {
|
|
180
|
+
const sign = min >= 0 ? '+' : '-';
|
|
181
|
+
const abs = Math.abs(min);
|
|
182
|
+
const hh = String(Math.floor(abs / 60)).padStart(2, '0');
|
|
183
|
+
const mm = String(abs % 60).padStart(2, '0');
|
|
184
|
+
return `${sign}${hh}:${mm}`;
|
|
185
|
+
};
|
|
186
|
+
const toLocalRfc3339 = (iso, offMin) => {
|
|
187
|
+
if (!iso)
|
|
188
|
+
return undefined;
|
|
189
|
+
const d = new Date(iso);
|
|
190
|
+
if (isNaN(d.getTime()))
|
|
191
|
+
return iso;
|
|
192
|
+
const y = d.getFullYear();
|
|
193
|
+
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
194
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
195
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
196
|
+
const mi = String(d.getMinutes()).padStart(2, '0');
|
|
197
|
+
const ss = String(d.getSeconds()).padStart(2, '0');
|
|
198
|
+
return `${y}-${m}-${day}T${hh}:${mi}:${ss}${formatOffset(offMin)}`;
|
|
199
|
+
};
|
|
200
|
+
const triggerAtLocal = toLocalRfc3339(triggerAt, offsetMin);
|
|
177
201
|
return {
|
|
178
202
|
content: [
|
|
179
203
|
{
|
|
180
204
|
type: 'text',
|
|
181
|
-
text: JSON.stringify({ id: resp.data?.id, triggerAt: resp.data?.triggerAt, msg: resp.msg || '设置成功' }, null, 2),
|
|
205
|
+
text: JSON.stringify({ id: resp.data?.id, triggerAt: resp.data?.triggerAt, triggerAtLocal, msg: resp.msg || '设置成功' }, null, 2),
|
|
182
206
|
},
|
|
183
207
|
],
|
|
184
208
|
isError: false,
|