How to get Time in twig? - twig

enter image description here
Good Morning .. I want t add a condition like {% if time > 18 H and time < 22 H %}
Payer
{%endif%}
I don't know how can i get the time in twig ??

You can do it like this:
{% if 'now'|date("H") > 18 and 'now'|date("H") < 22 %}
If you're talking about current time.

Related

Gantt chart reduce horizontal spacing between blocks

Am new to Gantt chart and facing some issues between the block in horizontel view .
Say i have 3 block , block 1 start time is at 5 and end time is 10 and block 2 start time is at 10 and endtime is at 15 and block 3 starttime is at 100 and endtime is at 105.
if you notice the above data , block 1 and block 2 are in sequence , but block 3 is located far away from block 2
Is there a way i can reduce the gap between block2 and block3 horizontelly ?
We cant manually edit the time of block3 , since there will be number of blocks and we are not sure about it .
So is there a way i can reduce the gaps between the block in horizontel in gantt chart ?

KQL - Query Usage Time

i have a Question about a Query in KQL.
I would like to use a Time at the KQL Query who only shows me the Results between 08:00 and 17:00 Time.
How can i build these at the KQL Query?
Im only find the DateTime Variable but i need only the Time?
Thanks a lot.
Regards,
Phil
The below is the example to show logs between specific time:
let start=datetime("10/26/2022 1:04:27.627 AM");
let end=datetime("10/26/2022 1:22:53.745 AM");
traces
| where timestamp > start and timestamp < end
If you only want timestamp then:
let start=datetime("10/26/2022 1:04:27.627 AM");
let end=datetime("10/26/2022 1:22:53.745 AM");
traces
| where timestamp > start and timestamp < end
| project timestamp
You can give your date and time in end and start in query.
Timestamp%1d will give us only the time part of the day (timespan).
// Data sample generation. Not part of the solution.
let t = materialize (range i from 1 to 20 step 1 | extend Timestamp = ago(7d * rand()));
// Solution starts here.
t
| where Timestamp%1d between (8h .. 17h)
| order by Timestamp%1d asc // Just for display
i
Timestamp
13
2022-10-19T08:26:45.2144968Z
1
2022-10-23T12:00:21.8528635Z
16
2022-10-19T12:50:27.4405648Z
19
2022-10-19T13:00:48.9000836Z
2
2022-10-24T13:19:30.956558Z
8
2022-10-25T13:51:25.726857Z
10
2022-10-22T14:12:09.8304847Z
7
2022-10-25T14:51:14.3011525Z
14
2022-10-20T15:21:04.5173436Z
11
2022-10-20T16:04:06.412613Z
12
2022-10-19T16:48:54.0581289Z
Fiddle

Twig logical operator not working for views result counter field in Drupal 8

I've a simple views where I intend to use the "Views result counter" field for altering the output HTML. The total number of rows returned by the view is 6, and I've added below condition in a "Global: Custom Text" field
{% if counter > 3 %}
<div>Greater than 3</div>
<div>{{ counter }}</div>
{% else %}
<div>Less than 3</div>
<div>{{ counter }}</div>
{% endif %}
The output is as below
Less than 3
1
Less than 3
2
Less than 3
3
Less than 3
4
Less than 3
5
Less than 3
6
It never goes inside the If condition

Excel If Function for Multiple If's

For the below, I'm looking for an excel if function that'll let me know how old each of the items are (less than 3 days, Less than 7 days, Less than 14 days, Greater than 14 days)
Create a table outlining your cut offs and then use a VLOOKUP.
In C2, add =VLOOKUP(TODAY()-B2,$F$2:$G$6,2,1) and drag down as needed
The benefit with going this route is that you don't have to update complicated IF statements if you ever needed to change the buckets. Say for instance, in the future you want to add 5 more categories. Here that would just mean updating 5 rows on a single table rather nesting 5 more criteria to an IF statement.
A simple verbose formula...
=IF(TODAY()-B3<=7,"Less than equal to seven",IF(TODAY()-B3<=14,"Less than or
equal to fourteen days",IF(TODAY()-B3<=21,"Less than or equal to twenty one
days","greater than 21 days")))
Need to format the cell this is in as a number with no decimal places.
This formula should do the trick:
=IF((TODAY()-B1)<3,"Less than 3 days",
IF((TODAY()-B1)<7,"Less than 7 days",
IF((TODAY()-B1)<14,"Less than 14 days",
IF((TODAY()-B1)>=14,"Greater than 14 days",""))))
Please notice that I used >=14.
Reason is otherwise you wont get the rows where the difference is exactly 14.
But feel free to change it to >14 if that's fit your need better :)
you can use tha TODAY() function to get the current date and than compare it with the dates you have:
so the table that you will have is like:
table, th, td {
border: 1px solid black;
}
<table style="width:100%">
<tr>
<th>5/12/2020</th>
<th>=TODAY()-B1</th>
<th>=if(C1<3, "less than 3 days", if(C1<7, "less than 7 days", if(C1<14, "less than 14 days", "more than 14 days")))
</th>
</tr>
<tr>
<th>5/10/2020</th>
<th>=TODAY()-B2</th>
<th>=if(C1<3, "less than 3 days", if(C1<7, "less than 7 days", if(C1<14, "less than 14 days", "more than 14 days")))
</th>
</tr>
</table>

Desk Check Binary Search

I am here about a query that I am facing.
I was wondering on how I would go about desk checking the following code.
Data set
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
4 7 19 25 36 37 50 100 101 205 220 271 306 321 456 500 /* Numbers are a bit messed up */
Algorithm
binarySearch
SET found TO FALSE
SET bottom TO zero
SET top TO sizeOfList-1
WHILE ( NOT found AND bottom <= top )
SET middle TO (bottom+top) DIV 2
IF searchValue < list element middle THEN
SET top TO middle-1
ELSE
IF searchValue > list element middle THEN
SET bottom TO middle+1
ELSE
SET position TO middle
SET found TO TRUE
ENDIF
ENDIF
ENDWHILE
IF NOT found THEN
RETURN –1
ELSE
RETURN position
ENDIF
The best way to do this is to first draw up a table, with one column for each variable (found, bottom, top, etc.). Then, "be" the computer, step through your program code one line at a time (probably best to write down each line number that you visit to keep track), taking the conditional branches based on the values in your table. Every time you modify a variable, add a new row to your table with the updated values. Eventually, you should reach a return statement, and then you're done.

Resources