How can I display the TimeSpec within a QDateTimeEdit object? - qt

I am working in QT Creator and would like to add text within the widget that displays the TimeSpec for this DateTime widget which is UTC. For example, I want it to show "1/1/00 5:00:00 AM (UTC)" as opposed to what it's showing right now. I went through the property list and didn't see anything that would allow me to make this change. Is it possible?

You have to set the displayFormat to M/d/yy h:mm:ss AP (t) and the timeSpec to UTC:

Related

How to change month descriptions on a DevExtreme Calendar?

I'm using the Calendar and DateBox components from DevExtreme.
My current language is set to pt-BR.
As shown in the image, the months descriptions are like "jan." but I'd like it to be "Jan".
Looking for some samples/demos on the internet (example1 or example2), the description as "Jan" is the default behaviour.
The code I'm using (the simplest):
Html.DevExtreme().DateBox()
.Type(DateBoxType.Date)
As a result of this, I'm trying to use DisplayFormat as "MMM/yyyy" and it makes the description like "jan./2021" and not "Jan/2021" as I'd like to.
Is there a way I can change this behaviour?
Try with "MM/yyyy" instead of "MMM/yyyy", it should work

EasyAdmin 3 datetime picker time format

How to change native easy admin 3 in symfony date/time picker time format? It now renders month, day, year. How do you set to 'Y-m-d H:i'?
If you look in the source code for the DateTimeField you will find a setFormat method that accepts a valid ICU Datetime Pattern (see http://userguide.icu-project.org/formatparse/datetime).
The format of a native date picker is determined by the browser's native code and locale settings, you cannot change it with out some complicated scripting (see here). This may possibly update the format of a choice or text type (not tested).
Try something like this:
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
public function configureFields(string $pageName): iterable
{
return [
// native date picker format cannot be changed
// Uses native HTML5 widgets when rendering this field in forms.
DateTimeField::new('beginsAt')->setFormat('Y-MM-dd HH:mm')->renderAsNativeWidget(),
// Uses <select> lists when rendering this field in forms.
DateTimeField::new('beginsAt')->setFormat('Y-MM-dd HH:mm')->renderAsChoice(),
// Uses <input type="text"> elements when rendering this field in forms.
DateTimeField::new('beginsAt')->setFormat('Y-MM-dd HH:mm')->renderAsText(),
];
}

Qt: how to save QTextEdit contents with custom properties

I have a text editor (QTextEdit). Some words in my editor contains additional information attached (namely, two corresponding integer positions in wave file for that word).
They are stored in Python object as custom properties for QTextCharFormat objects (I attach them with code like this: self.editor.textCursor().setCharFormat(QTextCharFormat().setProperty(MyPropertyID, myWordAttachment) )
Unfortunately, if I save my document to html, all of that additional formatting is lost.
So, I want to perform simplest task: to save my document with all of it's formatting,including myWordAttachment (and to load it from disk).
Am I right that Qt5 doesn't have something ready for it, and I have to write all that document's serialization code by myself? (I still hope that where is simple function that did the job)
1.you loop your text every character.
2.and you catch the character and its charFormat()
3.and you get the properties.
4.Because the properties are eventually a value of something, int,str,...
So you get the properties by charFormat().property(1),(2),(3)... or properties()
5.The most important thing is the character's position & the range.You get the position during the 1th loop.
6.When you catch the CharFormats, you insert into something hashable object like list.
& and you don't forget to insert the CharFormats position.
6.you save your document and the position & properties.
My suggestion for your solution.
1.you can get characterCount() by the QTextDocument object.
2.you loop the range of the characterCount()
3.Before doing it, you make a QTextCursor object.
4.you set the textcursor at the first position.(movePosition method & Start moveoperation & KeepAnchor flag)
5.you move the cursor to right one character & Another.
6.you check the character's charFormat() by tc.charFormat() and the tc.position()
7.But it is the time to Think twice. CharFormat is always the bunch of characters.
you probably get some characters of the same CharFormat().
You can prepare for it.I can Think about some way,but... you should set the QCharFormat objectType or propertyId() for specifing the QCharFormat in Advance(during editing your document).Why don't you set the texts into the properties for after saving & loading.I hope you manage to pass here during debugging & tring.
8.if you get a charFormat,and you check the objectType().
9.if the objectType() is the same as Before searched, you pass the search engine without doing anything.
10.The second important thing is that calls clearSelection() each searching.
11.You save your document() as it is html strings.and you save the charFormats() properties.
12.when you load your document(),the html sentence comes back.
and load the properties.
you make QTextCursor and setPosition( the property's position saved in advance.)
you move QTextCursor until the position and you select the target texts.
you adopt the charFormat properties again and the end.
Summary
The important thing how you specify the charFormat().
You can catch the charFormat without any problem.but the charFormat() is adopted in some range.So you must distinguish the range.
1.The targeted texts is set in the QTextCharFormat's property.
2.You have The QTextCursor pass during the same QTextCharFormat's object.
I can Think of them...
I Think it is some helps for you.

Vaadin Datefield doesn't recognize weeks in SimpleDateTime formats

My core problem is that I want to show the year's week number and the year itself in a Vaadin date-field. For example the user picks the 6th February 2018. The date-field should format its value like "06 2018".
As I understood the documentation of Vaadin 7.7.13, this should easily possible with:
public class CalendarWeekField extends DateField {
public CalendarWeekField() {
super();
this.setLocale(UI.getCurrent().getLocale());
this.setDateFormat("ww yyyy");
this.setShowISOWeekNumbers(true);
}
Please recognize the line this.setDateFormat("ww yyyy"); since it contains the actual "magic".
The date and time are normally displayed according to the default
format for the current locale (see Locale). You can specify a custom
format with setDateFormat(). It takes a format string that follows the
format of the SimpleDateFormat in Java.
However, following the above example, the output of the DateField is only " 2018".
What do I need to consider to get the year's week numbers displayed?
Consulted documentations:
Java SimpleDateFormat
Vaadin Date and Time Input with DateField - Date and Time Format
Vaadin 7.7.13 API Documentation DateField - setDateFormat(...)
I would call this a bug, your code is fine. You can even "fiddle around" with their live sampler (hit properties -> date format), the field excepts most date patterns but ww (and apparently some timezone-properties). File a bug report maybe?
Maybe you can walk around it by applying a change listener and using .setText() yourself? You would not need to extend the DateField in that case (actually there is no need to extend the field in the first place, simply create and set your properties).

DateTime in PropertyGrid in .Net

I'm currently working on some DateTime properties in a PropertyGrid in c#.Net. Im using the default drop-down datetime picker.
My question: Is there any way to show the full date with the time? By default the date is shown if no time is set, but I want zero-values aswell. I.e: I want "09.11.2009 00:00" to be shown instead of "09.11.2009".
Do I have to use some custom TypeConverter or Editor for this?
I feel so lost in this propertygrid and it makes me sad...
Any help would be appreciated! Thanks :)
Yes, you need your own TypeConverter. Derive it from DateTimeConverter and override the ConvertTo method. If you look this method in Reflector you will see this piece of code inside:
if (time.TimeOfDay.TotalSeconds == 0.0)
return time.ToString("yyyy-MM-dd", culture);
Just remove that for example.
Nicolas

Resources