mirror of
https://github.com/iib0011/omni-tools.git
synced 2026-04-22 13:16:23 +05:30
Merge pull request #351 from wz-Tan/wz-Tan
feat: Convert Date to Unix Tool
This commit is contained in:
commit
7a02327fd9
15 changed files with 351 additions and 145 deletions
|
|
@ -59,19 +59,23 @@
|
|||
}
|
||||
},
|
||||
"convertUnixToDate": {
|
||||
"addUtcLabel": "Suffix „UTC“ hinzufügen",
|
||||
"addUtcLabelDescription": "Anzeige „UTC“ nach dem konvertierten Datum (nur für den UTC-Modus)",
|
||||
"description": "Konvertieren Sie einen Unix-Zeitstempel in ein für Menschen lesbares Datum.",
|
||||
"addUtcLabel": "Suffix \"UTC\" hinzufügen",
|
||||
"addUtcLabelDescription": "Anzeige \"UTC\" nach dem konvertierten Datum (nur für den UTC-Modus)",
|
||||
"date-to-unix": "Datum → Unix",
|
||||
"description": "Unix-Zeitstempel in lesbare Daten und Datumsangaben in Unix-Zeitstempel konvertieren (beide Richtungen).",
|
||||
"optionsTitle": "Konvertierungsmodus",
|
||||
"outputOptions": "Ausgabeoptionen",
|
||||
"shortDescription": "Unix-Zeitstempel in Datum konvertieren",
|
||||
"title": "Konvertieren Sie Unix in Datum",
|
||||
"shortDescription": "Unix-Zeitstempel und Daten in beide Richtungen konvertieren.",
|
||||
"title": "Unix ↔ Datum konvertieren",
|
||||
"toolInfo": {
|
||||
"description": "Dieses Tool konvertiert einen Unix-Zeitstempel (in Sekunden) in ein lesbares Datumsformat (z. B. JJJJ-MM-TT HH:MM:SS). Es unterstützt sowohl die lokale als auch die UTC-Ausgabe und eignet sich daher für die schnelle Interpretation von Zeitstempeln aus Protokollen, APIs oder Systemen, die Unix-Zeit verwenden.",
|
||||
"title": "Konvertieren Sie Unix in Datum"
|
||||
"description": "Dieses Tool konvertiert Unix-Zeitstempel (in Sekunden) in menschenlesbare Datumsformate wie YYYY-MM-DD HH:MM:SS und konvertiert auch formatierte Daten zurück in Unix-Zeitstempel. Sie können UTF-Ausgabe, lokale Zeitzone oder einen benutzerdefinierten UTC-Offset wählen (z.B.: YYYY-MM-DD HH:MM:SS +XX:XX). Wenn kein Offset angegeben und lokale Zeitzone nicht ausgewählt ist, wird standardmäßig UTC (+00:00) verwendet.",
|
||||
"title": "Unix ↔ Datum konvertieren"
|
||||
},
|
||||
"tzOptions": "Zeitzonen-Optionen",
|
||||
"unix-to-date": "Unix → Datum",
|
||||
"useLocalTime": "Lokale Zeit verwenden",
|
||||
"useLocalTimeDescription": "Zeigen Sie das konvertierte Datum in Ihrer lokalen Zeitzone anstelle von UTC an",
|
||||
"withLabel": "Optionen"
|
||||
"useLocalTimeDescription": "Zeige das konvertierte Datum in deiner lokalen Zeitzone statt UTC an",
|
||||
"useUTC": "UTC verwenden"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "Generieren und verstehen Sie Cron-Ausdrücke. Erstellen Sie Cron-Zeitpläne für automatisierte Aufgaben und Systemjobs.",
|
||||
|
|
|
|||
|
|
@ -66,51 +66,27 @@
|
|||
},
|
||||
"convertUnixToDate": {
|
||||
"addUtcLabel": "Add 'UTC' suffix",
|
||||
"addUtcLabelDescription": "Display 'UTC' after the converted date (only for UTC mode)",
|
||||
"description": "Convert a Unix timestamp to a human-readable date.",
|
||||
"outputOptions": "Output Options",
|
||||
"shortDescription": "Convert Unix timestamp to date",
|
||||
"title": "Convert Unix to Date",
|
||||
"addUtcLabelDescription": "Append 'UTC' after the converted date (available only in UTC mode)",
|
||||
"description": "Convert Unix timestamps to readable dates and convert dates back to Unix timestamps.",
|
||||
"shortDescription": "Convert Unix timestamps and dates in both directions.",
|
||||
"title": "Convert Unix ↔ Date",
|
||||
"toolInfo": {
|
||||
"description": "This tool converts a Unix timestamp (in seconds) into a human-readable date format (e.g., YYYY-MM-DD HH:MM:SS). It supports both local and UTC output, making it useful for quickly interpreting timestamps from logs, APIs, or systems that use Unix time.",
|
||||
"title": "Convert Unix to Date"
|
||||
"title": "Convert Unix ↔ Date",
|
||||
"description": "This tool converts Unix timestamps (in seconds) into human-readable date formats such as YYYY-MM-DD HH:MM:SS, and also converts formatted dates back into Unix timestamps. You can choose UTC output, local timezone output, or provide a custom UTC offset (for example: YYYY-MM-DD HH:MM:SS +XX:XX). If no offset is provided and local timezone is not selected, UTC (+00:00) is used by default."
|
||||
},
|
||||
"useLocalTime": "Use Local Time",
|
||||
"useLocalTimeDescription": "Show converted date in your local timezone instead of UTC",
|
||||
"withLabel": "Options"
|
||||
"useUTC": "Use UTC",
|
||||
"useLocalTimeDescription": "Display the converted date in your local timezone instead of UTC",
|
||||
"tzOptions": "Timezone Options",
|
||||
"optionsTitle": "Conversion Mode",
|
||||
"date-to-unix": "Date → Unix",
|
||||
"unix-to-date": "Unix → Date"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "Generate and understand cron expressions. Create cron schedules for automated tasks and system jobs.",
|
||||
"shortDescription": "Generate and understand cron expressions",
|
||||
"title": "Crontab Guru"
|
||||
},
|
||||
"discordTimestamp": {
|
||||
"description": "Convert dates and times into Discord's special timestamp format that automatically adapts to each user's local timezone and language",
|
||||
"formats": {
|
||||
"description": "Choose how the timestamp will appear in Discord — hover over each option to see an example",
|
||||
"long_date": "Long Date (ex: 1 January 2025)",
|
||||
"long_datetime": "Long Date & Time (ex: Monday, 1 January 2025 14:30)",
|
||||
"long_time": "Long Time (ex: 14:30:00)",
|
||||
"relative": "Relative (ex: 2 hours ago)",
|
||||
"short_date": "Short Date (ex: 01/01/2025)",
|
||||
"short_datetime": "Short Date & Time (ex: 1 January 2025 14:30)",
|
||||
"short_time": "Short Time (ex: 14:30)",
|
||||
"title": "Timestamp Format"
|
||||
},
|
||||
"inputTitle": "Input Datetimes",
|
||||
"name": "Discord Timestamp Generator",
|
||||
"outputTitle": "Discord Timestamps",
|
||||
"shortDescription": "Generate Discord timestamps from dates",
|
||||
"toolInfo": {
|
||||
"description": "Discord timestamps are a special syntax that displays dates and times dynamically. Instead of showing a fixed time, they automatically convert to each viewer's local timezone and language — so everyone sees the correct time for their location. Simply enter one datetime per line, choose a format, and paste the results directly into Discord. The tool processes each line independently — blank lines are preserved in the output, invalid lines are flagged with ❌, and valid datetimes are converted instantly. Enable UTC mode to ensure consistent results regardless of your local timezone.",
|
||||
"title": "What is a Discord Timestamp?"
|
||||
},
|
||||
"utc": {
|
||||
"description": "Treat input datetimes as UTC. Disable to use your local timezone instead",
|
||||
"label": "Enforce UTC",
|
||||
"title": "Input Options"
|
||||
}
|
||||
},
|
||||
"timeBetweenDates": {
|
||||
"description": "Calculate the time difference between two dates. Get the exact duration in days, hours, minutes, and seconds.",
|
||||
"endDate": "End Date",
|
||||
|
|
@ -146,5 +122,45 @@
|
|||
"zeroPaddingDescription": "Make all time components always be two digits wide.",
|
||||
"zeroPrintDescription": "Display the dropped parts as zero values \"00\".",
|
||||
"zeroPrintTruncatedParts": "Zero-print Truncated Parts"
|
||||
},
|
||||
"discordTimestamp": {
|
||||
"name": "Discord Timestamp Generator",
|
||||
"description": "Convert dates and times into Discord's special timestamp format that automatically adapts to each user's local timezone and language",
|
||||
"shortDescription": "Generate Discord timestamps from dates",
|
||||
"inputTitle": "Input Datetimes",
|
||||
"outputTitle": "Discord Timestamps",
|
||||
"formats": {
|
||||
"title": "Timestamp Format",
|
||||
"description": "Choose how the timestamp will appear in Discord — hover over each option to see an example",
|
||||
"short_time": "Short Time (ex: 14:30)",
|
||||
"long_time": "Long Time (ex: 14:30:00)",
|
||||
"short_date": "Short Date (ex: 01/01/2025)",
|
||||
"long_date": "Long Date (ex: 1 January 2025)",
|
||||
"short_datetime": "Short Date & Time (ex: 1 January 2025 14:30)",
|
||||
"long_datetime": "Long Date & Time (ex: Monday, 1 January 2025 14:30)",
|
||||
"relative": "Relative (ex: 2 hours ago)"
|
||||
},
|
||||
"utc": {
|
||||
"title": "Input Options",
|
||||
"label": "Enforce UTC",
|
||||
"description": "Treat input datetimes as UTC. Disable to use your local timezone instead"
|
||||
},
|
||||
"toolInfo": {
|
||||
"title": "What is a Discord Timestamp?",
|
||||
"description": "Discord timestamps are a special syntax that displays dates and times dynamically. Instead of showing a fixed time, they automatically convert to each viewer's local timezone and language — so everyone sees the correct time for their location. Simply enter one datetime per line, choose a format, and paste the results directly into Discord. The tool processes each line independently — blank lines are preserved in the output, invalid lines are flagged with ❌, and valid datetimes are converted instantly. Enable UTC mode to ensure consistent results regardless of your local timezone."
|
||||
}
|
||||
},
|
||||
"convertDateToUnix": {
|
||||
"description": "Convert a human-readable date to a Unix Timestamp.",
|
||||
"outputOptions": "Output Options",
|
||||
"shortDescription": "Convert date to Unix timestamp.",
|
||||
"title": "Convert Date to Unix",
|
||||
"toolInfo": {
|
||||
"description": "This tool converts a human-readable date format (e.g., YYYY-MM-DD HH:MM:SS) into a Unix Timestamp. The user can choose to specify a given UTC offset (e.g., YYYY-MM-DD HH:MM:SS +XX:XX) or use the local timezone. If the user doesn't provide either an offset or choose to use the local timezone, the result is given with an offset of +00:00. ",
|
||||
"title": "Convert Date to Unix"
|
||||
},
|
||||
"useLocalTime": "Use Local Time",
|
||||
"useLocalTimeDescription": "The input time and date is processed as your browser's time zone. Additional specifications will be ignored.",
|
||||
"options": "Options"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,17 +61,21 @@
|
|||
"convertUnixToDate": {
|
||||
"addUtcLabel": "Añadir el sufijo 'UTC'",
|
||||
"addUtcLabelDescription": "Mostrar 'UTC' después de la fecha convertida (solo para el modo UTC)",
|
||||
"description": "Convierte una marca de tiempo de Unix en una fecha legible para humanos.",
|
||||
"date-to-unix": "Fecha → Unix",
|
||||
"description": "Convierte marcas de tiempo de Unix en fechas legibles y convierte fechas formateadas nuevamente en marcas de tiempo de Unix (en ambas direcciones).",
|
||||
"optionsTitle": "Modo de conversión",
|
||||
"outputOptions": "Opciones de salida",
|
||||
"shortDescription": "Convertir la marca de tiempo de Unix a fecha",
|
||||
"title": "Convertir Unix a fecha",
|
||||
"shortDescription": "Convierte marcas de tiempo de Unix y fechas en ambas direcciones.",
|
||||
"title": "Convertir Unix ↔ Fecha",
|
||||
"toolInfo": {
|
||||
"description": "Esta herramienta convierte una marca de tiempo Unix (en segundos) a un formato de fecha legible (p. ej., AAAA-MM-DD HH:MM:SS). Admite salida local y UTC, lo que la hace útil para interpretar rápidamente marcas de tiempo de registros, API o sistemas que usan hora Unix.",
|
||||
"title": "Convertir Unix a fecha"
|
||||
"description": "Esta herramienta convierte marcas de tiempo de Unix (en segundos) en formatos de fecha legibles para humanos como YYYY-MM-DD HH:MM:SS, y también convierte fechas formateadas nuevamente en marcas de tiempo de Unix. Puedes elegir salida UTC, salida de zona horaria local o proporcionar un desplazamiento UTC personalizado (por ejemplo: YYYY-MM-DD HH:MM:SS +XX:XX). Si no se proporciona ningún desplazamiento y no se selecciona la zona horaria local, se utiliza UTC (+00:00) por defecto.",
|
||||
"title": "Convertir Unix ↔ Fecha"
|
||||
},
|
||||
"useLocalTime": "Utilice la hora local",
|
||||
"tzOptions": "Opciones de zona horaria",
|
||||
"unix-to-date": "Unix → Fecha",
|
||||
"useLocalTime": "Utilizar la hora local",
|
||||
"useLocalTimeDescription": "Mostrar la fecha convertida en su zona horaria local en lugar de UTC",
|
||||
"withLabel": "Opciones"
|
||||
"useUTC": "Usar UTC"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "Generar y comprender expresiones cron. Crear programaciones cron para tareas automatizadas y trabajos del sistema.",
|
||||
|
|
|
|||
|
|
@ -61,18 +61,21 @@
|
|||
"convertUnixToDate": {
|
||||
"addUtcLabel": "Ajouter le suffixe 'UTC'",
|
||||
"addUtcLabelDescription": "Affiche 'UTC' après la date convertie (uniquement en mode UTC)",
|
||||
"description": "Convertit un timestamp Unix en une date lisible par un humain.",
|
||||
"longDescription": "Cet outil permet de convertir un timestamp Unix (en secondes) en une date lisible au format AAAA-MM-JJ HH:MM:SS. Il prend en charge l'affichage en UTC ou dans le fuseau horaire local, ce qui est pratique pour interpréter rapidement des horodatages issus de journaux, d'API ou de systèmes utilisant le temps Unix.",
|
||||
"date-to-unix": "Date → Unix",
|
||||
"description": "Convertir les horodatages Unix en dates lisibles et reconvertir les dates formatées en horodatages Unix (dans les deux directions).",
|
||||
"optionsTitle": "Mode de conversion",
|
||||
"outputOptions": "Options de sortie",
|
||||
"shortDescription": "Conversion de timestamp Unix en date",
|
||||
"title": "Convertir un timestamp Unix en date",
|
||||
"shortDescription": "Convertir les horodatages Unix et les dates dans les deux directions.",
|
||||
"title": "Convertir Unix ↔ Date",
|
||||
"toolInfo": {
|
||||
"description": "Cet outil convertit un timestamp Unix (en secondes) en une date lisible (par ex. AAAA-MM-JJ HH:MM:SS). Il prend en charge l'affichage en heure locale ou en UTC, ce qui le rend utile pour analyser rapidement des données issues de journaux ou d’APIs.",
|
||||
"title": "Convertir un timestamp Unix en date"
|
||||
"description": "Cet outil convertit les horodatages Unix (en secondes) en formats de date lisibles par l'homme tels que YYYY-MM-DD HH:MM:SS, et convertit également les dates formatées en horodatages Unix. Vous pouvez choisir la sortie UTC, la sortie du fuseau horaire local ou fournir un décalage UTC personnalisé (par exemple : YYYY-MM-DD HH:MM:SS +XX:XX). Si aucun décalage n'est fourni et que le fuseau horaire local n'est pas sélectionné, UTC (+00:00) est utilisé par défaut.",
|
||||
"title": "Convertir Unix ↔ Date"
|
||||
},
|
||||
"useLocalTime": "Utiliser l’heure locale",
|
||||
"useLocalTimeDescription": "Affiche la date convertie dans votre fuseau horaire local au lieu de l’heure UTC",
|
||||
"withLabel": "Options"
|
||||
"tzOptions": "Options de fuseau horaire",
|
||||
"unix-to-date": "Unix → Date",
|
||||
"useLocalTime": "Utiliser l'heure locale",
|
||||
"useLocalTimeDescription": "Affiche la date convertie dans votre fuseau horaire local au lieu de l'heure UTC",
|
||||
"useUTC": "Utiliser l'UTC"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "Générez et comprenez les expressions Cron. Créez des planifications Cron pour les tâches automatisées et les tâches système.",
|
||||
|
|
|
|||
|
|
@ -92,17 +92,21 @@
|
|||
"convertUnixToDate": {
|
||||
"addUtcLabel": "'UTC' प्रत्यय जोड़ें",
|
||||
"addUtcLabelDescription": "परिवर्तित तिथि के बाद 'UTC' प्रदर्शित करें (केवल UTC मोड के लिए)",
|
||||
"description": "यूनिक्स टाइमस्टैम्प को मानव-पठनीय दिनांक में परिवर्तित करें।",
|
||||
"date-to-unix": "दिनांक → यूनिक्स",
|
||||
"description": "यूनिक्स टाइमस्टैम्प को पठनीय दिनांकों में परिवर्तित करें और स्वरूपित दिनांकों को वापस यूनिक्स टाइमस्टैम्प में परिवर्तित करें (दोनों दिशाओं में)।",
|
||||
"optionsTitle": "रूपांतरण मोड",
|
||||
"outputOptions": "आउटपुट विकल्प",
|
||||
"shortDescription": "यूनिक्स टाइमस्टैम्प को दिनांक में परिवर्तित करें",
|
||||
"title": "यूनिक्स को दिनांक में परिवर्तित करें",
|
||||
"shortDescription": "यूनिक्स टाइमस्टैम्प और दिनांकों को दोनों दिशाओं में परिवर्तित करें।",
|
||||
"title": "यूनिक्स ↔ दिनांक रूपांतरित करें",
|
||||
"toolInfo": {
|
||||
"description": "यह उपकरण यूनिक्स टाइमस्टैम्प (सेकंड में) को मानव-पठनीय दिनांक प्रारूप (जैसे, YYYY-MM-DD HH:MM:SS) में परिवर्तित करता है। यह स्थानीय और UTC दोनों आउटपुट का समर्थन करता है, जिससे यह लॉग, API, या यूनिक्स समय का उपयोग करने वाले सिस्टम से टाइमस्टैम्प की त्वरित व्याख्या करने के लिए उपयोगी हो जाता है।",
|
||||
"title": "यूनिक्स को दिनांक में परिवर्तित करें"
|
||||
"description": "यह उपकरण यूनिक्स टाइमस्टैम्प (सेकंड में) को मानव-पठनीय दिनांक प्रारूप जैसे YYYY-MM-DD HH:MM:SS में परिवर्तित करता है, और स्वरूपित दिनांकों को वापस यूनिक्स टाइमस्टैम्प में भी परिवर्तित करता है। आप UTC आउटपुट, स्थानीय समय क्षेत्र आउटपुट, या कस्टम UTC ऑफ़सेट प्रदान कर सकते हैं (उदाहरण: YYYY-MM-DD HH:MM:SS +XX:XX)। यदि कोई ऑफ़सेट प्रदान नहीं किया गया है और स्थानीय समय क्षेत्र का चयन नहीं किया गया है, तो डिफ़ॉल्ट रूप से UTC (+00:00) का उपयोग किया जाता है।",
|
||||
"title": "यूनिक्स ↔ दिनांक रूपांतरित करें"
|
||||
},
|
||||
"tzOptions": "समय क्षेत्र विकल्प",
|
||||
"unix-to-date": "यूनिक्स → दिनांक",
|
||||
"useLocalTime": "स्थानीय समय का उपयोग करें",
|
||||
"useLocalTimeDescription": "परिवर्तित तिथि को UTC के बजाय अपने स्थानीय समय क्षेत्र में दिखाएँ",
|
||||
"withLabel": "विकल्प"
|
||||
"useUTC": "UTC का उपयोग करें"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"countPlaceholder": "संख्या",
|
||||
|
|
|
|||
|
|
@ -61,17 +61,21 @@
|
|||
"convertUnixToDate": {
|
||||
"addUtcLabel": "「UTC」サフィックスを追加",
|
||||
"addUtcLabelDescription": "変換された日付の後に「UTC」を表示します(UTCモードのみ)",
|
||||
"description": "Unix タイムスタンプを人間が読める日付に変換します。",
|
||||
"date-to-unix": "日付 → Unix",
|
||||
"description": "Unix タイムスタンプを読み取り可能な日付に変換し、フォーマットされた日付を Unix タイムスタンプに変換します(両方向)。",
|
||||
"optionsTitle": "変換モード",
|
||||
"outputOptions": "出力オプション",
|
||||
"shortDescription": "Unixタイムスタンプを日付に変換する",
|
||||
"title": "Unix を日付に変換する",
|
||||
"shortDescription": "Unix タイムスタンプと日付を両方向に変換します。",
|
||||
"title": "Unix ↔ 日付を変換する",
|
||||
"toolInfo": {
|
||||
"description": "このツールは、Unixタイムスタンプ(秒単位)を人間が判読できる日付形式(例:YYYY-MM-DD HH:MM:SS)に変換します。ローカルタイムスタンプとUTCタイムスタンプの両方の出力をサポートしているため、ログ、API、またはUnixタイムを使用するシステムからのタイムスタンプを素早く解釈するのに役立ちます。",
|
||||
"title": "Unix を日付に変換する"
|
||||
"description": "このツールは、Unix タイムスタンプ(秒単位)を YYYY-MM-DD HH:MM:SS などの人間が判読できる日付形式に変換し、フォーマットされた日付を Unix タイムスタンプに変換します。UTC出力、ローカルタイムゾーン出力、またはカスタム UTC オフセット(例:YYYY-MM-DD HH:MM:SS +XX:XX)を選択できます。オフセットが提供されず、ローカル タイムゾーンが選択されていない場合、デフォルトで UTC (+00:00) が使用されます。",
|
||||
"title": "Unix ↔ 日付を変換する"
|
||||
},
|
||||
"tzOptions": "タイムゾーンオプション",
|
||||
"unix-to-date": "Unix → 日付",
|
||||
"useLocalTime": "現地時間を使用する",
|
||||
"useLocalTimeDescription": "UTC ではなくローカルタイムゾーンで変換された日付を表示します",
|
||||
"withLabel": "オプション"
|
||||
"useUTC": "UTC を使用する"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "cron式を生成し、理解します。自動化されたタスクやシステムジョブのcronスケジュールを作成します。",
|
||||
|
|
|
|||
|
|
@ -61,17 +61,21 @@
|
|||
"convertUnixToDate": {
|
||||
"addUtcLabel": "Voeg 'UTC'-achtervoegsel toe",
|
||||
"addUtcLabelDescription": "'UTC' weergeven na de geconverteerde datum (alleen voor UTC-modus)",
|
||||
"description": "Converteer een Unix-tijdstempel naar een voor mensen leesbare datum.",
|
||||
"date-to-unix": "Datum → Unix",
|
||||
"description": "Converteer Unix-tijdstempels naar leesbare datums en converteer geformatteerde datums terug naar Unix-tijdstempels (in beide richtingen).",
|
||||
"optionsTitle": "Conversie-modus",
|
||||
"outputOptions": "Uitvoeropties",
|
||||
"shortDescription": "Unix-tijdstempel naar datum converteren",
|
||||
"title": "Unix naar Date converteren",
|
||||
"shortDescription": "Converteer Unix-tijdstempels en datums in beide richtingen.",
|
||||
"title": "Unix ↔ Datum converteren",
|
||||
"toolInfo": {
|
||||
"description": "Deze tool converteert een Unix-tijdstempel (in seconden) naar een voor mensen leesbaar datumformaat (bijv. JJJJ-MM-DD UU:MM:SS). De tool ondersteunt zowel lokale als UTC-uitvoer, waardoor het handig is voor het snel interpreteren van tijdstempels uit logs, API's of systemen die Unix-tijd gebruiken.",
|
||||
"title": "Unix naar Date converteren"
|
||||
"description": "Deze tool converteert Unix-tijdstempels (in seconden) naar voor mensen leesbare datumformaten zoals JJJJ-MM-DD UU:MM:SS, en converteert ook geformatteerde datums terug naar Unix-tijdstempels. U kunt UTC-uitvoer, lokale tijdzoneuitvoer of een aangepaste UTC-offset opgeven (bijvoorbeeld: JJJJ-MM-DD UU:MM:SS +XX:XX). Als er geen offset is opgegeven en lokale tijdzone niet is geselecteerd, wordt standaard UTC (+00:00) gebruikt.",
|
||||
"title": "Unix ↔ Datum converteren"
|
||||
},
|
||||
"tzOptions": "Tijdzone-opties",
|
||||
"unix-to-date": "Unix → Datum",
|
||||
"useLocalTime": "Gebruik lokale tijd",
|
||||
"useLocalTimeDescription": "Toon de geconverteerde datum in uw lokale tijdzone in plaats van UTC",
|
||||
"withLabel": "Opties"
|
||||
"useUTC": "UTC gebruiken"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "Genereer en begrijp cron-expressies. Maak cron-schema's voor geautomatiseerde taken en systeemtaken.",
|
||||
|
|
|
|||
|
|
@ -61,17 +61,21 @@
|
|||
"convertUnixToDate": {
|
||||
"addUtcLabel": "Adicionar sufixo 'UTC'",
|
||||
"addUtcLabelDescription": "Exibir 'UTC' após a data convertida (somente para o modo UTC)",
|
||||
"description": "Converta um registro de data e hora Unix em uma data legível por humanos.",
|
||||
"date-to-unix": "Data → Unix",
|
||||
"description": "Converta registros de data e hora Unix em datas legíveis e converta datas formatadas de volta para registros de data e hora Unix (em ambas as direções).",
|
||||
"optionsTitle": "Modo de conversão",
|
||||
"outputOptions": "Opções de saída",
|
||||
"shortDescription": "Converter registro de data e hora Unix em data",
|
||||
"title": "Converter Unix para Data",
|
||||
"shortDescription": "Converta registros de data e hora Unix e datas em ambas as direções.",
|
||||
"title": "Converter Unix ↔ Data",
|
||||
"toolInfo": {
|
||||
"description": "Esta ferramenta converte um registro de data e hora Unix (em segundos) em um formato de data legível (por exemplo, AAAA-MM-DD HH:MM:SS). Ela suporta saída local e UTC, o que a torna útil para interpretar rapidamente registros de data e hora de logs, APIs ou sistemas que utilizam o horário Unix.",
|
||||
"title": "Converter Unix para Data"
|
||||
"description": "Esta ferramenta converte registros de data e hora Unix (em segundos) em formatos de data legíveis para humanos, como AAAA-MM-DD HH:MM:SS, e também converte datas formatadas de volta para registros de data e hora Unix. Você pode escolher saída UTC, saída de fuso horário local ou fornecer um deslocamento UTC personalizado (por exemplo: AAAA-MM-DD HH:MM:SS +XX:XX). Se nenhum deslocamento for fornecido e o fuso horário local não estiver selecionado, UTC (+00:00) será usado por padrão.",
|
||||
"title": "Converter Unix ↔ Data"
|
||||
},
|
||||
"tzOptions": "Opções de fuso horário",
|
||||
"unix-to-date": "Unix → Data",
|
||||
"useLocalTime": "Usar hora local",
|
||||
"useLocalTimeDescription": "Mostrar a data convertida no seu fuso horário local em vez de UTC",
|
||||
"withLabel": "Opções"
|
||||
"useUTC": "Usar UTC"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "Gere e compreenda expressões cron. Crie agendamentos cron para tarefas automatizadas e trabalhos do sistema.",
|
||||
|
|
|
|||
|
|
@ -61,17 +61,21 @@
|
|||
"convertUnixToDate": {
|
||||
"addUtcLabel": "Добавить суффикс «UTC»",
|
||||
"addUtcLabelDescription": "Отображать «UTC» после преобразованной даты (только для режима UTC)",
|
||||
"description": "Преобразовать временную метку Unix в удобочитаемую дату.",
|
||||
"date-to-unix": "Дата → Unix",
|
||||
"description": "Преобразуйте временные метки Unix в читаемые даты и обратно преобразуйте отформатированные даты в временные метки Unix (в обе стороны).",
|
||||
"optionsTitle": "Режим преобразования",
|
||||
"outputOptions": "Параметры вывода",
|
||||
"shortDescription": "Преобразовать временную метку Unix в дату",
|
||||
"title": "Конвертировать Unix в дату",
|
||||
"shortDescription": "Преобразуйте временные метки Unix и даты в обе стороны.",
|
||||
"title": "Преобразовать Unix ↔ Дату",
|
||||
"toolInfo": {
|
||||
"description": "Этот инструмент преобразует временную метку Unix (в секундах) в удобный для восприятия формат даты (например, ГГГГ-ММ-ДД ЧЧ:ММ:СС). Он поддерживает как локальный формат, так и формат UTC, что делает его полезным для быстрой интерпретации временных меток из журналов, API или систем, использующих время Unix.",
|
||||
"title": "Конвертировать Unix в дату"
|
||||
"description": "Этот инструмент преобразует временные метки Unix (в секундах) в удобный для восприятия формат даты, такой как ГГГГ-ММ-ДД ЧЧ:ММ:СС, и также преобразует отформатированные даты обратно в временные метки Unix. Вы можете выбрать вывод UTC, вывод местного часового пояса или предоставить пользовательский смещение UTC (например: ГГГГ-ММ-ДД ЧЧ:ММ:СС +XX:XX). Если смещение не предоставлено и местный часовой пояс не выбран, по умолчанию используется UTC (+00:00).",
|
||||
"title": "Преобразовать Unix ↔ Дату"
|
||||
},
|
||||
"tzOptions": "Параметры часового пояса",
|
||||
"unix-to-date": "Unix → Дата",
|
||||
"useLocalTime": "Использовать местное время",
|
||||
"useLocalTimeDescription": "Показывать преобразованную дату в вашем местном часовом поясе вместо UTC",
|
||||
"withLabel": "Параметры"
|
||||
"useUTC": "Использовать UTC"
|
||||
},
|
||||
"crontabGuru": {
|
||||
"description": "Генерируйте и анализируйте выражения cron. Создавайте расписания cron для автоматизированных задач и системных заданий.",
|
||||
|
|
|
|||
|
|
@ -65,20 +65,25 @@
|
|||
}
|
||||
},
|
||||
"convertUnixToDate": {
|
||||
"addUtcLabel": "添加“UTC”后缀",
|
||||
"addUtcLabelDescription": "转换后的日期后显示“UTC”(仅适用于 UTC 模式)",
|
||||
"description": "将 Unix 时间戳转换为人类可读的日期。",
|
||||
"addUtcLabel": "添加 \"UTC\" 后缀",
|
||||
"addUtcLabelDescription": "在转换的日期后显示 \"UTC\"(仅限 UTC 模式)",
|
||||
"date-to-unix": "日期 → Unix",
|
||||
"description": "将 Unix 时间戳转换为可读日期,并将格式化日期转换回 Unix 时间戳(双向转换)。",
|
||||
"optionsTitle": "转换模式",
|
||||
"outputOptions": "输出选项",
|
||||
"shortDescription": "将 Unix 时间戳转换为日期",
|
||||
"title": "将 Unix 转换为日期",
|
||||
"shortDescription": "双向转换 Unix 时间戳和日期。",
|
||||
"title": "转换 Unix ↔ 日期",
|
||||
"toolInfo": {
|
||||
"description": "此工具可将 Unix 时间戳(以秒为单位)转换为人类可读的日期格式(例如 YYYY-MM-DD HH:MM:SS)。它支持本地和 UTC 输出,因此可用于快速解释来自日志、API 或使用 Unix 时间的系统的时间戳。",
|
||||
"title": "将 Unix 转换为日期"
|
||||
"description": "此工具将 Unix 时间戳(以秒为单位)转换为人类可读的日期格式(例如,YYYY-MM-DD HH:MM:SS),并将格式化日期转换回 Unix 时间戳。您可以选择 UTC 输出、本地时区输出,或提供自定义 UTC 偏移(例如,YYYY-MM-DD HH:MM:SS +XX:XX)。如果未提供偏移且未选择本地时区,则默认使用 UTC (+00:00)。",
|
||||
"title": "转换 Unix ↔ 日期"
|
||||
},
|
||||
"useLocalTime": "使用当地时间",
|
||||
"useLocalTimeDescription": "显示以当地时区而非 UTC 转换的日期",
|
||||
"withLabel": "选项"
|
||||
"tzOptions": "时区选项",
|
||||
"unix-to-date": "Unix → 日期",
|
||||
"useLocalTime": "使用本地时间",
|
||||
"useLocalTimeDescription": "显示使用本地时区而非 UTC 转换的日期",
|
||||
"useUTC": "使用 UTC"
|
||||
},
|
||||
|
||||
"crontabGuru": {
|
||||
"description": "生成并理解 cron 表达式。为自动化任务和系统作业创建 cron 计划。",
|
||||
"shortDescription": "生成并理解 cron 表达式",
|
||||
|
|
|
|||
|
|
@ -1,28 +1,44 @@
|
|||
import { expect, describe, it } from 'vitest';
|
||||
import { convertUnixToDate } from './service';
|
||||
import { UnixDateConverter } from './service';
|
||||
import InitialValuesType from './types';
|
||||
|
||||
describe('convertUnixToDate', () => {
|
||||
const createOptions = (
|
||||
overrides: Partial<InitialValuesType> = {}
|
||||
): InitialValuesType => ({
|
||||
mode: 'unix-to-date',
|
||||
withLabel: true,
|
||||
useLocalTime: false,
|
||||
...overrides
|
||||
});
|
||||
|
||||
describe('UnixDateConverter', () => {
|
||||
it('should convert a single Unix timestamp with label (UTC)', () => {
|
||||
const input = '0';
|
||||
const result = convertUnixToDate(input, true, false);
|
||||
const result = UnixDateConverter(input, createOptions());
|
||||
expect(result).toBe('1970-01-01 00:00:00.000 UTC');
|
||||
});
|
||||
|
||||
it('should convert a single Unix timestamp without label (UTC)', () => {
|
||||
const input = '1234567890';
|
||||
const result = convertUnixToDate(input, false, false);
|
||||
const result = UnixDateConverter(
|
||||
input,
|
||||
createOptions({ withLabel: false })
|
||||
);
|
||||
expect(result).toBe('2009-02-13 23:31:30.000');
|
||||
});
|
||||
|
||||
it('should convert a single Unix timestamp in local time', () => {
|
||||
const input = '1234567890';
|
||||
const result = convertUnixToDate(input, true, true);
|
||||
const result = UnixDateConverter(
|
||||
input,
|
||||
createOptions({ useLocalTime: true })
|
||||
);
|
||||
expect(result.endsWith('UTC')).toBe(false);
|
||||
});
|
||||
|
||||
it('should handle multiple lines with label (UTC)', () => {
|
||||
const input = '0\n2147483647';
|
||||
const result = convertUnixToDate(input, true, false);
|
||||
const result = UnixDateConverter(input, createOptions());
|
||||
expect(result).toBe(
|
||||
'1970-01-01 00:00:00.000 UTC\n2038-01-19 03:14:07.000 UTC'
|
||||
);
|
||||
|
|
@ -30,7 +46,13 @@ describe('convertUnixToDate', () => {
|
|||
|
||||
it('should handle multiple lines with local time', () => {
|
||||
const input = '1672531199\n1721287227';
|
||||
const result = convertUnixToDate(input, false, true);
|
||||
const result = UnixDateConverter(
|
||||
input,
|
||||
createOptions({
|
||||
withLabel: false,
|
||||
useLocalTime: true
|
||||
})
|
||||
);
|
||||
const lines = result.split('\n');
|
||||
expect(lines.length).toBe(2);
|
||||
expect(lines[0].endsWith('UTC')).toBe(false);
|
||||
|
|
@ -38,19 +60,22 @@ describe('convertUnixToDate', () => {
|
|||
|
||||
it('should return empty string for invalid input', () => {
|
||||
const input = 'not_a_number';
|
||||
const result = convertUnixToDate(input, true, false);
|
||||
const result = UnixDateConverter(input, createOptions());
|
||||
expect(result).toBe('');
|
||||
});
|
||||
|
||||
it('should return empty string for empty input', () => {
|
||||
const input = '';
|
||||
const result = convertUnixToDate(input, false, false);
|
||||
const result = UnixDateConverter(
|
||||
input,
|
||||
createOptions({ withLabel: false })
|
||||
);
|
||||
expect(result).toBe('');
|
||||
});
|
||||
|
||||
it('should ignore invalid lines in multiline input', () => {
|
||||
const input = 'abc\n1600000000';
|
||||
const result = convertUnixToDate(input, true, false);
|
||||
const result = UnixDateConverter(input, createOptions());
|
||||
expect(result).toBe('\n2020-09-13 12:26:40.000 UTC');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,14 +7,16 @@ import ToolTextResult from '@components/result/ToolTextResult';
|
|||
import { GetGroupsType } from '@components/options/ToolOptions';
|
||||
import { CardExampleType } from '@components/examples/ToolExamples';
|
||||
import CheckboxWithDesc from '@components/options/CheckboxWithDesc';
|
||||
import { convertUnixToDate } from './service';
|
||||
import { UnixDateConverter } from './service';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import InitialValuesType from './types';
|
||||
import SimpleRadio from '@components/options/SimpleRadio';
|
||||
|
||||
const initialValues = {
|
||||
const initialValues: InitialValuesType = {
|
||||
mode: 'unix-to-date',
|
||||
withLabel: true,
|
||||
useLocalTime: false
|
||||
};
|
||||
type InitialValuesType = typeof initialValues;
|
||||
|
||||
const exampleCards: CardExampleType<InitialValuesType>[] = [
|
||||
{
|
||||
|
|
@ -27,7 +29,11 @@ const exampleCards: CardExampleType<InitialValuesType>[] = [
|
|||
sampleResult: `1970-01-01 00:00:00:000 UTC
|
||||
2024-07-18 10:00:27:000 UTC
|
||||
2038-01-19 03:14:07:000 UTC`,
|
||||
sampleOptions: { withLabel: true, useLocalTime: false }
|
||||
sampleOptions: {
|
||||
mode: 'unix-to-date',
|
||||
withLabel: true,
|
||||
useLocalTime: false
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Without UTC Suffix',
|
||||
|
|
@ -37,15 +43,39 @@ const exampleCards: CardExampleType<InitialValuesType>[] = [
|
|||
1672531199`,
|
||||
sampleResult: `2009-02-13 23:31:30
|
||||
2022-12-31 23:59:59:000`,
|
||||
sampleOptions: { withLabel: false, useLocalTime: false }
|
||||
sampleOptions: {
|
||||
mode: 'unix-to-date',
|
||||
withLabel: false,
|
||||
useLocalTime: false
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Use Local Time',
|
||||
title: 'Basic Date to Unix',
|
||||
description:
|
||||
'This example demonstrates how timestamps are shown in your local timezone rather than UTC. The UTC suffix is omitted in this case.',
|
||||
sampleText: `1721287227`,
|
||||
sampleResult: `2024-07-18 12:00:27`,
|
||||
sampleOptions: { withLabel: true, useLocalTime: true }
|
||||
'In this example, a plain human-readable timeframe is converted into a Unix timestamp. The UTC offset is treated as +00:00. ',
|
||||
sampleText: `1990-03-17 14:23:00
|
||||
2012-12-21 00:00:00`,
|
||||
sampleResult: `637654980
|
||||
1356019200`,
|
||||
sampleOptions: {
|
||||
mode: 'date-to-unix',
|
||||
withLabel: true,
|
||||
useLocalTime: false
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'With UTC Offset Provided',
|
||||
description:
|
||||
'In this example, the UTC offset is provided after stating the timeframe with a space.',
|
||||
sampleText: `1985-06-15 12:00:00 +00:00
|
||||
2025-04-04 10:00:00 +08:00`,
|
||||
sampleResult: `487684800
|
||||
1743732000`,
|
||||
sampleOptions: {
|
||||
mode: 'date-to-unix',
|
||||
withLabel: true,
|
||||
useLocalTime: false
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
|
@ -54,8 +84,8 @@ export default function ConvertUnixToDate({ title }: ToolComponentProps) {
|
|||
const [input, setInput] = useState<string>('');
|
||||
const [result, setResult] = useState<string>('');
|
||||
|
||||
const compute = (values: typeof initialValues, input: string) => {
|
||||
setResult(convertUnixToDate(input, values.withLabel, values.useLocalTime));
|
||||
const compute = (values: InitialValuesType, input: string) => {
|
||||
setResult(UnixDateConverter(input, values));
|
||||
};
|
||||
|
||||
const getGroups: GetGroupsType<InitialValuesType> | null = ({
|
||||
|
|
@ -63,21 +93,46 @@ export default function ConvertUnixToDate({ title }: ToolComponentProps) {
|
|||
updateField
|
||||
}) => [
|
||||
{
|
||||
title: t('convertUnixToDate.withLabel'),
|
||||
title: t('convertUnixToDate.optionsTitle'),
|
||||
component: (
|
||||
<Box>
|
||||
<CheckboxWithDesc
|
||||
onChange={(val) => updateField('withLabel', val)}
|
||||
checked={values.withLabel}
|
||||
title={t('convertUnixToDate.addUtcLabel')}
|
||||
description={t('convertUnixToDate.addUtcLabelDescription')}
|
||||
<SimpleRadio
|
||||
onClick={() => updateField('mode', 'unix-to-date')}
|
||||
checked={values.mode === 'unix-to-date'}
|
||||
title={t('convertUnixToDate.unix-to-date')}
|
||||
/>
|
||||
<CheckboxWithDesc
|
||||
onChange={(val) => updateField('useLocalTime', val)}
|
||||
checked={values.useLocalTime}
|
||||
<SimpleRadio
|
||||
onClick={() => updateField('mode', 'date-to-unix')}
|
||||
checked={values.mode === 'date-to-unix'}
|
||||
title={t('convertUnixToDate.date-to-unix')}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: t('convertUnixToDate.tzOptions'),
|
||||
component: (
|
||||
<Box>
|
||||
<SimpleRadio
|
||||
onClick={() => updateField('useLocalTime', true)}
|
||||
checked={values.useLocalTime === true}
|
||||
title={t('convertUnixToDate.useLocalTime')}
|
||||
description={t('convertUnixToDate.useLocalTimeDescription')}
|
||||
/>
|
||||
<SimpleRadio
|
||||
onClick={() => updateField('useLocalTime', false)}
|
||||
checked={values.useLocalTime === false}
|
||||
title={t('convertUnixToDate.useUTC')}
|
||||
/>
|
||||
|
||||
{/* Only Show Add UTC Suffix Option on Convert Unix to Date and utc mode selected */}
|
||||
{values.mode === 'unix-to-date' && !values.useLocalTime && (
|
||||
<CheckboxWithDesc
|
||||
onChange={(val) => updateField('withLabel', val)}
|
||||
checked={values.withLabel}
|
||||
title={t('convertUnixToDate.addUtcLabel')}
|
||||
description={t('convertUnixToDate.addUtcLabelDescription')}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,19 @@
|
|||
import { containsOnlyDigits } from '@utils/string';
|
||||
import InitialValuesType from './types';
|
||||
import { parseDateInput } from '@utils/time';
|
||||
|
||||
// Unix to Date
|
||||
function computeUnixToDate(input: string, useLocalTime: boolean): string {
|
||||
if (!containsOnlyDigits(input)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (input.length > 10) return 'ms not supported, divide by 1000';
|
||||
|
||||
const timestamp = parseInt(input, 10);
|
||||
|
||||
const date = new Date(timestamp * 1000); // Convert from seconds to milliseconds
|
||||
if (isNaN(date.getTime())) return '';
|
||||
|
||||
if (useLocalTime) {
|
||||
const year = date.getFullYear();
|
||||
|
|
@ -20,23 +28,62 @@ function computeUnixToDate(input: string, useLocalTime: boolean): string {
|
|||
}
|
||||
}
|
||||
|
||||
export function convertUnixToDate(
|
||||
// Date to Unix
|
||||
function computeDateToUnix(input: string, useLocalTime: boolean): string {
|
||||
try {
|
||||
const { dateTime, utcOffset } = parseDateInput(input);
|
||||
const normalized = dateTime.includes(':')
|
||||
? dateTime
|
||||
: `${dateTime}T00:00:00`;
|
||||
|
||||
if (useLocalTime) {
|
||||
const localOffsetMinutes = new Date().getTimezoneOffset();
|
||||
const sign = localOffsetMinutes <= 0 ? '+' : '-';
|
||||
const absMinutes = Math.abs(localOffsetMinutes);
|
||||
const hh = String(Math.floor(absMinutes / 60)).padStart(2, '0');
|
||||
const mm = String(absMinutes % 60).padStart(2, '0');
|
||||
const unix = Date.parse(`${normalized}${sign}${hh}:${mm}`) / 1000;
|
||||
return isNaN(unix) ? '' : `${unix}`;
|
||||
}
|
||||
|
||||
if (utcOffset) {
|
||||
const valid = utcOffset.match(/^[+-](0\d|1[0-4]):(00|15|30|45)$|^Z$/);
|
||||
if (!valid) return '';
|
||||
const unix =
|
||||
Date.parse(`${normalized}${utcOffset === 'Z' ? 'Z' : utcOffset}`) /
|
||||
1000;
|
||||
return isNaN(unix) ? '' : `${unix}`;
|
||||
}
|
||||
|
||||
// Default: treat as UTC
|
||||
const unix = Date.parse(`${normalized}Z`) / 1000;
|
||||
return isNaN(unix) ? '' : `${unix}`;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export function UnixDateConverter(
|
||||
input: string,
|
||||
withLabel: boolean,
|
||||
useLocalTime: boolean
|
||||
options: InitialValuesType
|
||||
): string {
|
||||
const result: string[] = [];
|
||||
if (!input) return '';
|
||||
|
||||
const { mode, useLocalTime, withLabel } = options;
|
||||
|
||||
const lines = input.split('\n');
|
||||
|
||||
lines.forEach((line) => {
|
||||
const parts = line.split(' ');
|
||||
const timestamp = parts[0];
|
||||
const formattedDate = computeUnixToDate(timestamp, useLocalTime);
|
||||
|
||||
if (mode === 'unix-to-date') {
|
||||
const label = !useLocalTime && withLabel ? ' UTC' : '';
|
||||
result.push(formattedDate ? `${formattedDate}${label}` : '');
|
||||
});
|
||||
return lines
|
||||
.map((line) => {
|
||||
const formattedDate = computeUnixToDate(line.trim(), useLocalTime);
|
||||
return formattedDate ? `${formattedDate}${label}` : '';
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
return result.join('\n');
|
||||
return lines
|
||||
.map((line) => computeDateToUnix(line.trim(), useLocalTime))
|
||||
.join('\n');
|
||||
}
|
||||
|
|
|
|||
7
src/pages/tools/time/convert-unix-to-date/types.ts
Normal file
7
src/pages/tools/time/convert-unix-to-date/types.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export type mode = 'date-to-unix' | 'unix-to-date';
|
||||
|
||||
export default interface InitialValuesType {
|
||||
mode: mode;
|
||||
withLabel: boolean;
|
||||
useLocalTime: boolean;
|
||||
}
|
||||
|
|
@ -56,3 +56,23 @@ export function humanTimeValidation(input: string): TimeValidationResult {
|
|||
|
||||
return { isValid: true, hours, minutes, seconds };
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the datetime string and optional UTC offset from a raw input line.
|
||||
* Supports formats like:
|
||||
* "2026-04-11 10:00"
|
||||
* "2026-04-11 10:00 +02:00"
|
||||
* "2026-04-11T10:30:00Z"
|
||||
* "April 11, 2026 10:00 -05:00"
|
||||
*/
|
||||
export function parseDateInput(input: string): {
|
||||
dateTime: string;
|
||||
utcOffset: string | null;
|
||||
} {
|
||||
const match = input.trim().match(/^(.+?)\s*([+-]\d{2}:\d{2}|Z)$/);
|
||||
if (!match) return { dateTime: input.trim(), utcOffset: null };
|
||||
return {
|
||||
dateTime: match[1].trim(),
|
||||
utcOffset: match[2] ?? null
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue