Skip to content

Commit

Permalink
Allow datetime value to be null (#9897)
Browse files Browse the repository at this point in the history
* change valid date check

* add changeset

* move clear event and dispatch clear

* remove clear event

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
hannahblair and gradio-pr-bot authored Nov 7, 2024
1 parent d81f430 commit c0cf80b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/empty-humans-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/datetime": patch
"gradio": patch
---

fix:Allow datetime value to be null
6 changes: 3 additions & 3 deletions js/datetime/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script lang="ts">
import type { Gradio } from "@gradio/utils";
import { Block, BlockTitle } from "@gradio/atoms";
import { Back, Calendar } from "@gradio/icons";
import { Calendar } from "@gradio/icons";
export let gradio: Gradio<{
change: undefined;
Expand Down Expand Up @@ -54,8 +54,8 @@
let datetime: HTMLInputElement;
let datevalue = value;
const date_is_valid_format = (date: string): boolean => {
if (date === "") return false;
const date_is_valid_format = (date: string | null): boolean => {
if (date === null || date === "") return true;
const valid_regex = include_time
? /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/
: /^\d{4}-\d{2}-\d{2}$/;
Expand Down

0 comments on commit c0cf80b

Please sign in to comment.