core icon indicating copy to clipboard operation
core copied to clipboard

DateTimeFormat bug

Open granicz opened this issue 3 years ago • 0 comments

(From the Forums - https://forums.websharper.com/topic/91272)

Using v4.7.1, the following sitelet returns a 404 when trying to access /?date=2021-12-12. If I comment out the DateTimeFormat part then it returns the correct content when accessing /?date=2021-12-12-01.01.01

This example works correctly in v3 (with the appropriate change for generating the HTML).

The only workaround I can find is to use a string option instead of DateTime option and then do the date parsing myself.

type Routes =
    | [<EndPoint "GET /">] 
      [<Query("date")>]
      [<DateTimeFormat("date", "yyyy-MM-dd")>]
      Home of date: DateTime option

let site = Sitelet.Infer (fun ctx route ->
    match route with
    | Home date -> 
        Content.Page [ p [] [ sprintf "%A" date |> text ] ] )

granicz avatar Dec 17 '21 02:12 granicz