Skip to content
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

Creating a DateTime with DateTimeKind should use the DateTimeKind and not a literal int #3689

Open
MangelMaxime opened this issue Jan 4, 2024 · 0 comments

Comments

@MangelMaxime
Copy link
Member

Description

let d = DateTime(2014, 10, 9, 13, 23, 30, 234, DateTimeKind.Local)

generates

d: Any = create(2014, 10, 9, 13, 23, 30, 234, 2)

CleanShot 2024-01-04 at 22 41 34@2x

The code below should be changed to transform the literal enum into a call to the DateTimeKind types (currently located in util.py).

let last = List.last args
match args.Length, last.Type with
| 7, Number(_, NumberInfo.IsEnum ent) when
ent.FullName = "System.DateTimeKind"
->
let args =
(List.take 6 args)
@ [
makeIntConst 0
last
]
let argTypes =
(List.take 6 i.SignatureArgTypes)
@ [
Int32.Number
last.Type
]
Helper.LibCall(
com,
"Date",
"create",
t,
args,
argTypes,
?loc = r
)
|> Some
| _ ->
Helper.LibCall(
com,
moduleName,
"create",
t,
args,
i.SignatureArgTypes,
?loc = r
)
|> Some

The pylance warning is not harmful it is just to generate a Python code without error

Related information

  • Fable version: 4.9.0
  • Operating system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant