mclocks-datetime-util 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. package/README.md +2 -1
  2. package/package.json +1 -1
  3. package/server.js +19 -0
package/README.md CHANGED
@@ -9,6 +9,7 @@ An MCP (Model Context Protocol) server that gives AI assistants the ability to a
9
9
  | Tool | Description |
10
10
  |------|-------------|
11
11
  | **`current-time`** | Get the current time in your configured timezones |
12
+ | **`local-time`** | Get the current local time in the user's timezone (from `convtz` config or system default). Useful when other MCP tools or prompts need the user's local date/time |
12
13
  | **`convert-time`** | Convert a datetime string or epoch timestamp to multiple timezones |
13
14
  | **`next-weekday`** | Find the date of the next occurrence of a given weekday |
14
15
  | **`date-to-weekday`** | Get the day of the week for a given date |
@@ -54,7 +55,7 @@ If you use the [mclocks](https://github.com/bayashi/mclocks) desktop app, the MC
54
55
 
55
56
  - **`clocks`** — Timezones from your clocks become default conversion targets
56
57
  - **`convtz`** — Default source timezone for datetime strings without timezone info
57
- - **`usetz`** — Controls strict timezone conversion mode
58
+ - **`usetz`** — Enables strict timezone conversion for historically accurate UTC offsets (e.g. JST was +09:18 before 1888)
58
59
  - **`locale`** — Language for weekday names (e.g. `ja`, `pt`, `de`)
59
60
 
60
61
  Config file locations:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mclocks-datetime-util",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "MCP server for datetime and timezone conversion, powered by mclocks config",
5
5
  "type": "module",
6
6
  "bin": {
package/server.js CHANGED
@@ -125,6 +125,8 @@ function convertToTimezone(cdt, src, tz, usetz) {
125
125
  try {
126
126
  let result;
127
127
  if (usetz) {
128
+ // Use strict timezone conversion for historically accurate UTC offsets.
129
+ // For example, before 1888/1/1 00:00:00 in JST, its utcOffset is 09:18.
128
130
  result = cdt(src).tz(tz).text();
129
131
  } else {
130
132
  const offset = cdt().tz(tz).utcOffset();
@@ -265,6 +267,23 @@ server.tool(
265
267
  }
266
268
  );
267
269
 
270
+ server.tool(
271
+ "local-time",
272
+ "Get the current local time in the user's timezone (from convtz config or system default). Use this when other MCP tools or prompts need the user's local date/time.",
273
+ {},
274
+ async () => {
275
+ const tz = configConvTZ || Intl.DateTimeFormat().resolvedOptions().timeZone;
276
+ const source = configConvTZ ? "config (convtz)" : "system";
277
+ const now = new Date();
278
+ const cdt = cdate().cdateFn();
279
+ const offset = cdt().tz(tz).utcOffset();
280
+ const result = cdt(now).utcOffset(offset).text();
281
+ return {
282
+ content: [{ type: "text", text: `${result} in ${tz} (source: ${source})` }],
283
+ };
284
+ }
285
+ );
286
+
268
287
  server.tool(
269
288
  "next-weekday",
270
289
  "Find the date of the next occurrence of a given weekday from today.",