Number of days between two dates in Thymeleaf - spring-mvc

How do you get the number of days between two dates in Thymeleaf?
Progress up until now:
<span th:text="${#dates.format(#dates.createNow(), 'dd/MMM/yyyy HH:mm') - #dates.format(feed.dateCreated, 'dd/MMM/yyyy HH:mm')}">Number of Days</span>
Any help would be highly appreciable.
Thanks

As far as I know, this isn't something that Thymeleaf's utilities support, so it is kind of ugly to do. I tried this, and it works for me:
<span th:with="days=${T(java.util.concurrent.TimeUnit).DAYS}, millis=${T(java.util.concurrent.TimeUnit).MILLISECONDS}" th:text="${days.convert(#dates.createNow().getTime() - feed.dateCreated.getTime(), millis)}" />
Instead of doing all this in thymeleaf, I would probably add a getNumberOfDays() method to the feed object that returns the number of days and handle the diff in there. (Or use something like timeago.)

Here's what I did and it worked !
<span class="text-small" th:text="${task.timeEnd.getDate() - task.timeStart.getDate()} + ' Days' "></span>

Related

Adobe AEM Querybuilder Debugger - Multiple Paths and Multiple Nodenames

I am using querybuilder debugger and want to do a search where "nodename=.pdf OR nodename=.doc*" and "path=/content/dam/1 OR path=/content/dam/2".
I have been trying to find an example but no luck on the web. What I have below is not quite right - just wondering what I am missing.
The query does work but there is a huge difference in the amount of time that it runs when compared with when I just query using one nodename instead of 2.
Thanks in advance,
Jerry
type=dam:asset
mainasset=true
1_group.p.or=true
1_group.1.nodename=*.pdf
1_group.2.nodename=*.doc*
2_group.p.or=true
2_group.1_path=/content/dam/1
2_group.2_path=/content/dam/2
p.limit=-1
orderby=path
I thought maybe something as simple as this might work but no luck....
type=dam:asset
mainasset=true
group.p.or=true
group.1_nodename=*.doc*
group.1_path=/content/dam/1
group.2_nodename=*.doc*
group.2_path=/content/dam/2
group.3_nodename=*.pdf
group.3_path=/content/dam/1
group.4_nodename=*.pdf
group.4_path=/content/dam/2
p.limit=-1
orderby=path
Try splitting your query if this won't affect the behaviour you're trying to achieve.
path=/content/dam/1
type=dam:asset
mainasset=true
group.1.nodename=*.pdf
group.2.nodename=*.doc*
p.limit=-1
orderby=path
path=/content/dam/2
type=dam:asset
mainasset=true
group.1.nodename=*.pdf
group.2.nodename=*.doc*
p.limit=-1
orderby=path

Is it possible to pass class to binding attribute in Angular?

We have a solution based on a numeric field being set to 1 or 2 or displaying certain icons. It works.
<span *ngIf="config.icon"
[class.fas]="true"
[class.fa-plus]="icon===1"
[class.fa-minus]="icon===2"
class="indicator">
</span>
I sense what shortly, we'll have a whole bunch of such icons (about 15 different ones). The suggested solution is either to put in 15 lines of specific class assignments or to build a specialized component managing that.
I'm opposed to both but haven't got it working out when I tried and googling led to irrelevant hits. Possibly due to my incompetence recognized th egood stuff.
Is it possible to do something like one of the following pseudo code lines? How?
[class.fa-{{iconName}}]="true"
[class]="iconName"
edit
Based on the comments/answers, I got it working using the following.
<span *ngIf="config.icon"
[ngClass]='{ "fas": true, "fa-plus": true }'></span>
However, for some reason, I'm not getting anything using the syntax below.
<span *ngIf="config.icon"
[ngClass]="classes"></span>
...
classes: { "fas": true, "fa-plus": true };
What am I missing?
You can try something like this:
<span class= "indicator"
[class.fas]="true"
[ngClass]="'fa-' + iconName">
</span>
See working example at https://stackblitz.com/edit/angular-mgecjw

Variable Properties in LESS CSS

I am trying to create me a PX/REM converter in LESS CSS but I am facing a problem.
The following lines do not want to compile, the problem comes from #{propertyValue}:.
.rem(#propertyValue; #sizeValue) {
#remValue: #sizeValue / unit(#base-font-size);
#{propertyValue}: ~"#{remValue}rem";
}
But yet I think the syntax is good... at last I thought! Can you help me?
Thank you!
Are you using at least LESS 1.6? Variables as property names were added in 1.6. Prior to 1.6 there are some solutions but none are pretty.
Your snippet works in this LESS previewer which is running 1.6.0: less2css

Symfony2 translation pluralization arabic language

I have a problem with pluralization translation in symfony2 in my arabic yaml file.
I can't write interval correctly it always shuffle and give me error. I don't seem to find a way to write the sentence correcty because it always changes after I add a number and it become like this شخص|]1,Inf] أشخاص
please help me am really stuck!
recent: الأحدث
popular: الأكثر شعبية
Next: التالي
January: يناير
February: فبراير
March: مارس
April: أبريل
May: ماي
June: يونيو
July: يوليوز
August: غشت
September: شتنبر
October: أكتوبر
November: نونبر
December: دجنبر
You: أنتم
And: و
PERSON: شخص واحد
PERSONS: أشخاص
PERSON_PERSONS: شخص|]1,Inf] أشخاص
Print: طباعة
Thanks ferdynator i found the mistake i was making it's not about the letters shuffling it got interpreted , the problem was that i didn't manage all cases of pluralization i should add case {1}, solved!

Looking for a filter to modify the months

Hi making a simple plugin that replaces the wrong russian month with the right ones.
But I can't find any filters that works.
I have tried these filters without success:
add_filter('get_the_modified_date', 'russian-month');
add_filter('the_modified_date', 'russian-month');
add_filter('date_rewrite_rules', 'russian-month');
Just found out that you can use more functions as filters and not only the ones on http://codex.wordpress.org/Plugin_API/Filter_Reference#Date_and_Time_Filters
add_filter('get_the_date', 'russian-month');
did the trick for me :)

Resources