DateTime in PropertyGrid in .Net - datetime

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

Related

How to format datetime field to hours minutes seconds in form view in odoo 15

I have a datetime field and i want to format it to hours, minutes, seconds in the form view like this:
Is this posible, and how to do it?
Thanks.
As far as i can research, we can use this as alternative solution:
Change the field from Datetime to Float:
your_field = fields.Float(string='Your Field')
Then, in the form view, add widget="float_time":
<field name="your_field " widget="float_time"/>
And here's the result:
With this, there's no popup to show (It's bad, i know).
But as i mentioned before, this solution is just a alternative solution until we find better solution.
Other answers are welcome.
Note for the report view or email view, we can use this: t-options="{'widget': 'float_time'}"
Thanks.

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

Date.ftl - set current time

I'm using date.ftl to display date and time in Alfresco Share 4.2c, with parameter showTime set as true. Default time is 00:00. Is there a way to set current local time as the default time?
Is it better to try to change that in date.ftl or maybe in some associated .js file?
I was looking, but I couldn't find where it is set, so any help will be appreciated.
Changing existing date.ftl is not advisable.Instead of that you should create your own date control(you need to create both ftl and as well as javascript file),In that you need to change below things.
Change in tomcat\webapps\share\components\form\date-picker.js file(this should be file which you have created for your custom control).In onReady() function set the value of text box using javascript.

What is the standard way to get/set datetime from fluid in typo3 flow?

What is the standard way to get/set datetimes to/from fluid in typo3 flow?
Is there editable html field which - like a basic f:form.textfield - will allow the datetime to be entered, edited and persisted?
I know I can display a datetime with eg
<f:format.date format="d.m.Y - H:i:s">{productArticle.classdate}</f:format.date>
but in that case the value is null nothing gets displayed and no entry is possible anyway. Does property work with f:format.date in some version? I get "property not registered" when I try it.
Or do I need to have two fields on my page, one for date and one for time, that I put together in the Action?
Thanks
I'm not sure if it's standard way, and personally I don't like it.. but it can be done like this:
In Fluid for new/edit actions:
<f:form action="create" objectName="girlfriend">
...
<f:form.textfield property="birthDate" placeholder="1991-12-30 - 18:25:58" value="{newGirlfriend.birthDate->f:format.date(format:'Y-m-d - H:i:s')}" />
...
</f:form>
In your controller you can add initialize*Action and update propertyMappingConfiguration for \DateTime if standard isn't good for you (it has to be done for both create and update action):
public function initializeCreateAction() {
$mappingConfig = $this->arguments['girlfriend']->getPropertyMappingConfiguration();
$mappingConfig->forProperty('birthDate')->setTypeConverterOption(
'TYPO3\Flow\Property\TypeConverter\DateTimeConverter',
\TYPO3\Flow\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
'Y-m-d - H:i:s'
);
}
Sometimes it's easier to not pass object directly to controller but create it on service layer. You can also take a look at TypeConverters - they do not require initializeActions and you can easily override existing ones setting higher priority..

XPages: create current Datetime in ssjs and save to a Datetime Notes form field

The only way i have found to store date in a Datetime field in a notes form is this:
theDoc2.replaceItemValue("lastAccess",session.createDateTime("Today"));
But this only creates a Date, not DateTime. Also, i dont want to create a static time like "Today 12" but i want the current datetime dynamicly.
Using this i get an error (Exception occurred calling method NotesDocument.replaceItemValue(string, Date) null):
theDoc2.replaceItemValue("lastAccess",#Now());
and using this, the form field changes from Date/Time to Text data type and i want to keep Date/Time type:
theDoc2.replaceItemValue("lastAccess",#Now().toLocaleString);
Any ideas?
Just gave it a try:
as you wrote, .replaceItemValue("fieldName", #Now()) throws an error.
However, I got it to work with
.replaceItemValue("fieldName", session.createDateTime(#Now()))
In that case the value is stored in the Notes field as Time/Date with all necessary components as in
17.01.2014 12:45:51 CET
From what I can see, difference between the two is that #Now() returns a Date data type, whereas session.createDateTime() returns a NotesDateTime object
On the other hand, for me it's also working with your original method:
session.createDateTime("Today")
Don't know what's causing the prob on your side; do you have an editable represantion of the field on you xpage? If so, does it have some kind of converter enabled which could do some filtering during submit?
i will answer my own question as i found a way. Please comment if you think it is not correct or best practice...
theDoc2.replaceItemValue("lastAccess",session.createDateTime("Today"+#Now().toLocaleTimeString()));
A little late, but I had the same problem, but this method resolved it:
DateTime datumtijd = session.createDateTime("Today");
datumtijd.setNow(); //!!!!!!
System.out.println((datumtijd).toString());
Hope it helps :)

Resources