Compare commits
2
Commits
f3cd3b8086
...
ae030ea7f5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae030ea7f5 | ||
|
|
8007468abd |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tout-doux",
|
"name": "tout-doux",
|
||||||
"version": "1.7.7",
|
"version": "1.7.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "tout-doux"
|
name = "tout-doux"
|
||||||
version = "1.7.7"
|
version = "1.7.8"
|
||||||
description = ""
|
description = ""
|
||||||
requires-python = ">=3.14"
|
requires-python = ">=3.14"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { parseDateInput, formatDateInput } from "@/lib/dates";
|
||||||
|
|
||||||
const emit = defineEmits<(e: "input"|"change", value: Date) => void>();
|
const emit = defineEmits<(e: "input"|"change", value: Date) => void>();
|
||||||
|
|
||||||
const date = defineModel<Date>({ required: true });
|
const date = defineModel<Date>({ required: true });
|
||||||
|
|
||||||
|
|
||||||
function onInput(event: Event) {
|
function onInput(event: Event) {
|
||||||
const inputValue = (event.target as HTMLInputElement).value;
|
const inputValue = (event.target as HTMLInputElement).value;
|
||||||
date.value = new Date(inputValue);
|
date.value = parseDateInput(inputValue);
|
||||||
|
|
||||||
emit('input', date.value);
|
emit('input', date.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(event: Event) {
|
function onChange(event: Event) {
|
||||||
const inputValue = (event.target as HTMLInputElement).value;
|
const inputValue = (event.target as HTMLInputElement).value;
|
||||||
date.value = new Date(inputValue);
|
date.value = parseDateInput(inputValue);
|
||||||
emit('change', date.value);
|
emit('change', date.value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<input
|
<input
|
||||||
:value="date.toISOString().substring(0, 10)"
|
:value="formatDateInput(date)"
|
||||||
type="date"
|
type="date"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
|
|||||||
@@ -1,6 +1,22 @@
|
|||||||
import { formatDistanceToNow } from "date-fns";
|
import { formatDistanceToNow } from "date-fns";
|
||||||
import { enUS, fr } from "date-fns/locale";
|
import { enUS, fr } from "date-fns/locale";
|
||||||
|
|
||||||
|
export function parseDateInput(rawDate: string): Date {
|
||||||
|
const parts = rawDate.split('-').map(part => parseInt(part, 10));
|
||||||
|
if (!parts[0] || !parts[1] || !parts[2]) {
|
||||||
|
return new Date(new Date().setHours(0, 0, 0, 0))
|
||||||
|
}
|
||||||
|
return new Date(parts[0], parts[1] - 1, parts[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatDateInput(date: Date): string {
|
||||||
|
return [
|
||||||
|
date.getFullYear().toFixed(0),
|
||||||
|
(date.getMonth() + 1).toFixed(0).padStart(2, '0'),
|
||||||
|
(date.getDate()).toFixed(0).padStart(2, '0'),
|
||||||
|
].join('-');
|
||||||
|
}
|
||||||
|
|
||||||
export function relativeTime(date: Date, locale: string): string {
|
export function relativeTime(date: Date, locale: string): string {
|
||||||
return formatDistanceToNow(date, {
|
return formatDistanceToNow(date, {
|
||||||
addSuffix: true,
|
addSuffix: true,
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ asyncpg = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tout-doux"
|
name = "tout-doux"
|
||||||
version = "1.7.7"
|
version = "1.7.8"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "flask", extra = ["async"] },
|
{ name = "flask", extra = ["async"] },
|
||||||
|
|||||||
Reference in New Issue
Block a user