Can we get current date and calculate dates in a Jinja2 template? - date

Context:
There is a framework that processes Jinja2 templates and creates AWS resources based on the JSON file generated from the Jinja2 templates. One field value in these templates is a date.
Problem:
I want a template which automagically calculates the future date 5 days from the current date in the following format: MMDDYYYY, preferably without passing any parameter to this template file.
I have no means to alter the processing framework, so i can only work with what template i feed in.
Questions:
Can any of these done in a Jinja2 template file?
get current date
calculate date which is 5 days later than a provided date in
MMDDYYYY format

Related

Date format in HTTP GET for test/runs azure DevOps API query

I'm attempting to call the Azure DevOps API to determine the outcome for test runs using the URL, narrowing the results to a single releaseEnvId:
https://dev.azure.com/organisation/project/_apis/test/runs?api-version=5.0&releaseEnvIds=12345&minLastUpdatedDate=2019-05-17T14:00:00.910Z&maxLastUpdatedDate=2019-05-15T14:00:00.910Z
The API request requires two mandatory date-time fields, but the doc at https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/query?view=azure-devops-rest-5.0 does not specify the format:
maxLastUpdatedDate
minLastUpdatedDate
The date-time format I am specifying is wrong because the error comes up:
{"$id":"1","innerException":null,"message":"Invalid dates specified.","typeName":"Microsoft.TeamFoundation.TestManagement.WebApi.InvalidPropertyException, Microsoft.TeamFoundation.TestManagement.WebApi","typeKey":"InvalidPropertyException","errorCode":0,"eventId":3000}
As I understand the doc, the min date must be less than 7 days from the max. if I add garbage to the date formats then it produces a proper date parsing error.
The format you provided it's good but in your example the minLastUpdatedate (5/17) it's after the maxLastUpadeDate (5/15) in it should be the opposite. try to replace the values and it should work.
BTW - you specified the date in the full format, the API should works also with date only - 2019-05-15 or with a time - 2019-05-15T14:00:00.

Qlik Sense: Change date field format from Google Analytics API

I've pulled in data in Qlik Sense (cloud) from the Google Analytics connector. I'm trying to convert the standard date [ga_dateHourMinute] field to a more eligible date format.
The current format is YearMonthDayhHourMinute, for instance: 201810250004, I would like to convert this to the standard date format 2018-10-25 00:04:00. How do I do this? Answers concerning methods in the data load script or master formula's or variables are all welcome.
Click to see screenshot: left = current date format and right = desired date format
This is one approach:
DateAlter:
LOAD * INLINE [
Date
201810250004
];
DateAlter2:
LOAD
Date(Date#([Date], 'YYYYMMDDhhmm') ,'YYYY-MM-DD hh:mm') AS [MyDateField]
Resident
DateAlter;
If you haven't played around with the data manager, it will allow you to edit fields and handle dates in a fairly easy manner:
Qlik Sense Data Manager
I ended up creating a text fields that combined the different digits from the one field into a new order, then pushed the data format into a date/time. Quite a bit of work, but fairly solid.

Date related operations in jinja2

I am using cratejoy to create a 'subscription boxes' based website.It used jinja2 as its templating engine.
Now I am editing email templates where I want to access order items and send my customized messages.
My question is how to do date related operations using jinja2 syntax just as getting-
date on next monday,
next month name,
first monday of next month etc
I am able to do everything easiliy with javascript but it wont be helpful since email clients wont run JS.
Any help will be appreciated !!

SharePoint: Wrong Date in Word Template's Quick Part

I have a library with custom content type with .docx template.
I have a 'StartDate' and 'EndDate' fields in the content type which are mapped to quick parts in .docx template.
When I change the values of these two fields in item properties, it updates the values in document as well (as it's supposed to be).
PROBLEM
The values in the document are always one day off.
If for example I set the date to 15/04/2016, it shows 14/04/2016 on the document.
How can I make them equal?
The time zones and everything seems to be fine on SharePoint and on my local machine.
I believe this issue is being caused by the way SharePoint stores date and time values. From the SharePoint MSDN article on Converting Date and Time Values:
Microsoft SharePoint Foundation stores date and time values in Coordinated Universal Time (UTC) format, and almost all date and time values that are returned by members of the object model are in UTC format.
So when you enter a date and time into SharePoint in local time, SharePoint stores that information in Coordinated Universal Time (UTC). But when the mapped content control in Word retrieves the date/time value it receives the UTC equivalent of whatever your local date and time is (SharePoint itself automatically converts date and time values to your local time when displaying that information within its own user interface).
I think the best way to solve this would be to create calculated fields that are not displayed. The calculated fields would take the input date/time values from your 'StartDate' and 'EndDate' fields in the content type and correct them for your local UTC offset. You could then map the corrected calculated values to Quick Parts in your Word document.

Drupal 7 and Page Manager: add Selection rules based on dates

I have a content type article with a field date.
I am trying to fire a variant from Page Manager by defining a selection rule based on a date field.
What I am trying to do is applying this variant when
the node type is article
field date, start date < now < field date, end date
I can define the first condition but I can't figure out how to make a condition based on a date. Is it possible or not? I couldn't find more information about this.
Thanks
I managed to do this finally by writing a PHP Code Selection Rule.
I got from the exposed $contexts variable the start and end values for date field and I wrote a simple condition to check if "now" is in between the two dates.
Beware that the dates are stored in UTC format in the field and your site/users might be in a different timezone.