mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #99] Support for .NET DateTime type in Qml. #58
Labels
No labels
bug
enhancement
help wanted
help wanted
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/qmlnet#58
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MaxMommersteeg on GitHub (Dec 25, 2018).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/99
Now I have to convert it to string using a helper function on another .NET type: https://github.com/MaxMommersteeg/Qml.Net.Chat/blob/master/src/Qml.Net.Chat.Client/Controllers/ChatController.cs#L66
Can we build native support for this type, do I have to register the DateTime type or can we make this possible with the [Date Qml type] (http://doc.qt.io/qt-5/qml-qtqml-date.html)?
@pauldotknopf commented on GitHub (Dec 25, 2018):
In .NET,
System.DateTimeis horrible. Mainly because it doesn't contain the actual UTC offset. That means a date time value withLocalKindcould literally be any time.Because of this,
System.DateTimedoesn't translate well to other languages due to the missing precision.Instead, use
System.DateTimeOffset. It get's represeted perfectly in .NET and JS as fully featured and native date types.@MaxMommersteeg commented on GitHub (Dec 25, 2018):
Alright, you are definitely right about the System.DateTime type in .NET.
I can't directly use DateTimeOffset in Qml right? So do I need to register it like I register other types (as done in Program.cs), can I convert it to a javascript date or else?
@pauldotknopf commented on GitHub (Dec 25, 2018):
It gets automatically converted back-and-forth, it's a built-in supported data type in qmlnet.
Check the unit tests.
@MaxMommersteeg commented on GitHub (Dec 25, 2018):
Ah check, found it here: https://github.com/qmlnet/qmlnet/blob/develop/src/net/Qml.Net.Tests/Qml/DateTimeOffsetTests.cs
Perhaps I can focus on writing down features based on unittests and add them to the Github.io pages later this week.
I will close this issue, thanks!