Skip to content

Add unix-timestamp-converter extension #18949

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ride-space
Copy link

@ride-space ride-space commented May 5, 2025

Description

This PR adds a new Raycast extension: Unix Timestamp Converter.

Overview

Unix Timestamp Converter is a tool that allows you to easily convert between Unix timestamps (epoch seconds) and human-readable date and time formats (e.g., YYYY-MM-DD HH:mm:ss).
It streamlines the timestamp conversion tasks that engineers and developers often perform, making them quick and convenient right within Raycast.

Key Features

  • Convert Unix timestamps to local date and time
    Enter a Unix timestamp and instantly see it converted to the local date and time of your selected country or timezone.
  • Convert date and time to Unix timestamps
    Enter a date and time (e.g., 2024-06-01 12:34:56) and convert it to a Unix timestamp as if it were in the local time of your selected country or timezone.
  • One-click copy
    Easily copy the conversion result to your clipboard with a single click, making it simple to paste into other apps or services.

Supported Timezones

  • Japan (JST, Asia/Tokyo)
  • USA (New York: EST, America/New_York / Los Angeles: PST, America/Los_Angeles)
  • Korea (KST, Asia/Seoul)
  • Thailand (ICT, Asia/Bangkok)

Supported Date Formats

  • Japanese format (e.g., 2025/05/03(Sat) 22:02:33)
  • Korean format (e.g., 2025.05.03(Sat) 22:02:33)
  • Thai format (e.g., 2025/05/03(Sat) 22:02:33)
  • ISO 8601 format (e.g., 2025-05-03T13:02:33.000Z, UTC)
  • US English format (e.g., Saturday, May 3, 2025, 10:02:33 PM GMT+9)

How to Use

  1. Launch the "Unix Timestamp Converter" command in Raycast.
    2.2Enter the value you want to convert (either a Unix timestamp or a date), and select the country and display format.
  2. The conversion result is shown instantly, and you can copy it to your clipboard as needed.
    With this extension, you can quickly handle timestamp conversions directly in Raycast, without needing to search the web or use external tools.

Screencast

Convert Unix timestamps to local date and time

Convert.Unix.timestamps_to_local_date_and.time.mov

Convert date and time to Unix timestamps

Convert_date_and_time_to_Unix.timestamps.mov

Checklist

- chore(metadata): update screenshot images with resized versions
- feat(assets): add icon and screenshot images
- docs: add README and CHANGELOG
- chore(package): define extension metadata, commands, dependencies, and npm scripts in package.json
- feat(generate): add feature to convert date to UNIX timestamp
- feat(convert): add feature to convert UNIX timestamp to date
- feat(utils): implement date conversion and clipboard utility functions
- feat(constants): add supported countries and formats definitions
- chore(deps): add package-lock.json
- first commit
@raycastbot raycastbot added the new extension Label for PRs with new extensions label May 5, 2025
@raycastbot
Copy link
Collaborator

Congratulations on your new Raycast extension! 🚀

You can expect an initial review within five business days.

Once the PR is approved and merged, the extension will be available on our Store.

@ride-space ride-space marked this pull request as ready for review May 5, 2025 02:34
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Let me provide a concise review of this new Unix Timestamp Converter extension:

A comprehensive extension that enables conversion between Unix timestamps and human-readable dates across multiple timezones and formats, with a clean form-based interface and clipboard integration.

Key points:

  • Japanese comments in datetime.ts and types.ts should be translated to English to comply with Raycast's English-only localization policy
  • showFailureToast from @raycast/utils should be used in try-catch blocks instead of manual showToast calls for error handling
  • metadata folder with screenshots is missing but required since there are view commands in package.json
  • copyToClipboardWithToast in clipboard.ts should include error handling for clipboard access failures
  • Timezone offset calculations in getUnixTimeFromLocalDate() need to handle DST edge cases

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

13 file(s) reviewed, 19 comment(s)
Edit PR Review Bot Settings | Greptile

{
"name": "convert-timestamp",
"title": "Convert Timestamp",
"subtitle": "Unix Time Converter",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Both commands have the same subtitle 'Unix Time Converter'. Consider using the extension title as subtitle to help users identify which extension the command belongs to.

if (!country || !format) return;
const date = getDateFromUnixTime(Number(values.unixTime));
const result = format.format(date, country);
copyToClipboardWithToast(result.split(": ")[1] ?? "", "Datetime copied!");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Splitting on ': ' is fragile - consider using a more robust way to extract the formatted date portion

},
});

// 結果のプレビュー
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Japanese comment '結果のプレビュー' should be in English for consistency

Suggested change
// 結果のプレビュー
// Preview of the result

onSubmit(values) {
const country = countries.find((c) => c.id === values.country);
const format = formats.find((f) => f.id === values.format);
if (!country || !format) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Silent return on invalid country/format - should show error toast

Suggested change
if (!country || !format) return;
if (!country || !format) {
showFailureToast(new Error("Invalid country or format selected"));
return;
}

Comment on lines 2 to 3
* 国情報
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Raycast only supports US English. Comments should be in English instead of Japanese ('Country information')

Suggested change
* 国情報
*/
* Country information
*/

export type Country = {
id: string;
name: string;
timezoneOffset: number; // UTCからのオフセット(例: 9)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Comment should be in English ('UTC offset (e.g.: 9)')

Suggested change
timezoneOffset: number; // UTCからのオフセット(例: 9
timezoneOffset: number; // UTC offset (e.g.: 9)

Comment on lines 13 to 14
* 日時フォーマット
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Comment should be in English ('Date format')

Suggested change
* 日時フォーマット
*/
* Date format
*/

Comment on lines 25 to 26
* convert-timestampコマンド用フォーム値
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Comment should be in English ('Form values for convert-timestamp command')

Suggested change
* convert-timestampコマンド用フォーム値
*/
* Form values for convert-timestamp command
*/

Comment on lines 34 to 35
* generate-timestampコマンド用フォーム値
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Comment should be in English ('Form values for generate-timestamp command')

Suggested change
* generate-timestampコマンド用フォーム値
*/
* Form values for generate-timestamp command
*/

ride-space added 9 commits May 6, 2025 09:28
In the US, the 12-hour clock is standard, so hour12 was changed from false to true.
…g date value instead of string split

Changed the result of format.format to return an object with name and value properties.
Now, the date value is accessed directly from the value property, making the extraction more robust and maintainable.
@ride-space
Copy link
Author

@greptileai

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

Based on the recent changes, here's a focused review of the Unix Timestamp Converter extension updates:

A well-structured update that improves error handling, standardizes terminology, and enhances the overall code quality of the Unix Timestamp Converter extension.

Key points:

  • Standardized terminology from 'USA' to 'United States' across documentation for consistency
  • Added structured result objects with name and value properties in format functions
  • Improved form validation with proper error handling using showFailureToast
  • Simplified state management by using useState for result text
  • Added zero-padding utility for date components with well-documented pad2 function

The implementation shows good attention to detail and follows Raycast's best practices, particularly in error handling and user feedback mechanisms.

9 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +8 to +9
{ id: "japan", name: "Japan", timezoneOffset: 9, timezoneName: "JST", ianaTimeZone: "Asia/Tokyo" },
{ id: "new_york", name: "USA (New York)", timezoneOffset: -5, timezoneName: "EST", ianaTimeZone: "America/New_York" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: EST/PST are not fixed timezone names and change with daylight savings. Consider using ET/PT instead.

Comment on lines +97 to +99
format: (date, country) => {
return { name: `${country.name} Time (${country.timezoneName})`, value: date.toISOString() };
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Return type doesn't match other format functions which return strings. This will cause type inconsistency.

Suggested change
format: (date, country) => {
return { name: `${country.name} Time (${country.timezoneName})`, value: date.toISOString() };
},
format: (date, country) => {
return `${country.name} Time (${country.timezoneName}): ${date.toISOString()}`;
},

locale: string,
options: Intl.DateTimeFormatOptions,
): { name: string; value: string } => {
return {name : `${country.name} Time (${country.timezoneName})`, value: `${date.toLocaleString(locale, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Inconsistent spacing around object property name. Should be { name: not {name :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new extension Label for PRs with new extensions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants