TYPO3 groupedFor viewhelper according to dates - typo3

I have a simple model "item" with 3 properties:
title, description, date
Now I want to have a list like this:
10.10.17:
title item 1
title item 5
12.10.17:
title item 8
and so on
According to groupedFor - grouping objects according to dates
I added a getter like
/**
* Get day month year of datetime
*
* #return int
*/
public function getDayMonthYearOfDatetime()
{
return (int)$this->datum->format('dmy');
}
My list view:
<f:groupedFor each="{items}" as="dayMonthYearOfDatetime" groupBy="dayMonthYearOfDatetime" groupKey="datum">
<tr>
<th>{datum}</th>
</tr>
<f:for each="{dayMonthYearOfDatetime}" as="calendar">
<tr>
<td>{item.title}</td>
</tr>
</f:for>
</f:groupedFor>
Now I get the following output:
101017
title item 1
title item 5
121017
title item 8
How to diplay the correct date "10.10.17" instead "101017"?
If I change my getter to:
return (int)$this->datum->format('d.m.y');
It doesn't work.

return (int)$this->datum->format('d.m.y');
Remove the (int)

You can't expect to have a grouping if you return int from a date-string with dots.
Either you need to return string (but I don't know whether the function is allowed to return anything else than int) or you need to calculate your datestring from the calculated integer.
Try a viewhelper which does integer caclulations ( % 100, / 100 %100, /10000) or simple substrings (,0,2 ,2,2 ,4,2) to extract the values for day, month, year for a following concatenation.

You can simply use the real date object of the first group-item.
So it would be
<f:format.date format="d.m.Y">{dayMonthYearOfDatetime.0.datum}</f:format>

Related

IFS formula with date types as conditions

I have two different date types in my table: the first is simple YYYY-MM-DD, the second contains the week number and year.
How is it possible to build an IFS formula, where these two date types are conditions? Like:
=IFS(A1="YYYY-MM-DD", "A", A1="WWYYYY", "B")
You may simply use following formula:
=IFS(LEN(A1)=10,"A",len(A1)=6,"B")
I didn't see Google Sheets Data Format WWYYYY then I assumed that you have text values. If it's true then you can try REGEXMATCH
=IFS(REGEXMATCH(J8,"\d{4}-\d{2}-\d{2}"), "A",REGEXMATCH(J8,"\d{6}"), "B")
But for me I will not save Dates as text. It requires a script
/**
*
* #customformula
*/
function PATTERN_EXTRACTOR(pattern, a1Notations) {
var patt = new RegExp(pattern, 'gi');
var range = SpreadsheetApp.getActiveSheet().getRange(a1Notations);
return range.getDisplayValues().map(function(row) {
return row.map(function(cell) {
return cell.replace(patt,'X');
});
});
}
Getting pattern
=PATTERN_EXTRACTOR("\d",CELL("address",I8))
Resolve conditions
=IFS(I10="XXXX-XX-XX", "A",I10="XXXXXX", "B")
this could work too:
=ARRAYFORMULA(IF(IFERROR(DATEVALUE(A1:A5)), "A",
IF(ISNUMBER(A1:A5), "B", )))

Display holidays on antd's datepicker

Can someone tell me how to display holidays using antd-datepicker by getting holiday information from a server.
Before I call the dateRender callback, I want to get the startdate and the enddate of the holiday information.
Try this picking from the example:
<DatePicker
dateRender={(current) => {
const style = {};
if (InHolidayDates(current.date())) {
style.border = '1px solid #1890ff';
style.borderRadius = '50%';
}
return (
<div className="ant-calendar-date" style={style}>
{current.date()}
</div>
);
}}/>
Write a InHolidayDates(date) function which checks if the "date" is in the Holidays Date list. If it exists it returns true. Else false.
Let me know if you need help with the fetching and comparison of dates.

Date Time Functions in Algolia

I have an object in Algolia like -
{
…
“startDate”: “2013-09-26T00:00:00.000+05:30”,
“endDate”: “2017-10-25T10:08:44.000+05:30”,
…
}
Now, while retrieving the object i want to add another field as -
“endingIn”: “Ending in 9 days”
“endingIn” is days remaining from todays date till endDate. Example:
val daysLeft = Days.daysBetween(DateTime.now,DateTime.parse(endDate)).getDays <br>
val endingIn = s"Ending In $daysLeft days"
Is it possible?
Thanks in advance.
you can use transformData.
from the doc :Method used to change the object passed to the item template

Gravity Forms Date Push Reservations

I currently use GF for reservations 'Arrive' and 'Departure'. I would like the date displayed on the 'Departure' to always be one date ahead of the 'Arrival' date, regards of what date the guest picks. Then can pick a custom 'Departure' date, but as a default I'd like to show one date forward of the 'Arrival' date no matter what 'Arrival' date they choose.
This is possible with the gform_datepicker_options_pre_init JS filter. Example #3 is what you're after:
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 8 ) {
optionsObj.minDate = 0;
optionsObj.onClose = function (dateText, inst) {
jQuery('#input_12_9').datepicker('option', 'minDate', dateText).datepicker('setDate', dateText);
};
}
return optionsObj;
});
If you're looking for a code-less solution, I've written a plugin that let's you do this in just a few clicks called GP Limit Dates.
Also, here is an article that addresses your specific need: How to restrict dates in second date field based on date selected in first date field with Gravity Forms

How to generate form using Illuminate/HTML and database values in Laravel?

I saw this question: Generate drop-down list input with values from DB table, but the answer was not clear.
So, how can I generate form using Illuminate/HTML and database values in Laravel?
It's this simple.
First, you have to pass an array with the select values from the controller:
/**
* Show the form for creating a new resource.
*
* #return Response
*/
public function create()
{
$categories = Category::lists('name','id');
return view('myformview', compact('categories'));
}
Where "Category" is the model I want to retrieve data from. Note I am passing two values to the array. The first one is the text will be displayed in the select, and the second one is the value of the option.
Let's see now the form:
{!! Form::label('category_id', 'Category:') !!}<br>
{!! Form::select(
'category_id',
$categories
)
!!}
The first parameter of Form::select is the name of the select. The second one is the array with the options values.
In my particular case I get back this HTML code:
<select id="category_id" name="category_id">
<option value="5">First category</option>
<option value="6">Second category</option>
<option value="7">Third category</option>
</select>
I hope this will be helpful for you. I tested it in Laravel 5