I have a lambda function that needs to store an item in a DynamoDB table that is going to be used by AppSync. I want to add a createdAt and a updatedAt field to the item, as AWSDateTime types, and set them to the time of their creation. As explained here I need to use An extended ISO 8601 date and time string in the format YYYY-MM-DDThh:mm:ss.sssZ. I use:
import datetime from datetime
datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
but what it gives me is something like 2022-03-26T18:23:47Z instead of 2022-03-26T18:23:47.210Z for example (The three number-places after the second are absent).
Could you please help me fix this?
Milliseconds are optional. Reduced precision formats are valid ISO 8601 timestamps and thus valid AWSDateTime types.
If milliseconds are meaningful to your use case, there are several ways to add them:
datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
datetime.now().isoformat(timespec='milliseconds') + 'Z'
# '2022-03-27T11:05:10.351Z'
Related
There is a finite list of date formats that users want to use to enter a date in a form. These formats include single digits for month and day and double digits for year. The field is represented by a dateText control.
How would one get to allow a dateText control to accept multiple date formats ? I see only 3 listed (https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GZCP_forms_dateText), do those include using single digits for month and day ?
I tried to set the value of format = "#(myPageProperty.myValue)# " but I got a compilation error in Studio so that went nowhere. Has anyone ever been able to set the format value depending on the user input value?
I am guessing that the control input value must be converted to the YYYY-MM-DD before validation. I am open to calling a javascript function to do that but where would be the best place to put it?
for details see Class %ZEN.Component.dateText
setting format:
Property format As %ZEN.Datatype.string(MAXLEN = 3, **VALUELIST = ",MDY,DMY,YMD",** ZENEXPRESSION = 1)
you have exactly 3 formats or ""
Your guess on values is correct and documented:
/// The value of this control is always in the canonical form: YYYY-MM-DD
As this is one of the oldest components of ZEN your only chance to achieve
your way of operation is to create your own version inheriting from
Class %ZEN.Component.dateText and overloading the parts you want to change
I am new to freemarker.
In freemarker, I would like to perform arithmetic expression on DateTime as follows:
${triggerTimestamp}-1h
But this is not working. Could anyone please help here?
FreeMarker doesn't do date/time arithmetic out of the box (as of 2.3.30 at least). It's expected that the data-model (context) contains the values that you actually want to display. One can implement some helper method in Java though.
You'll want to explore converting the date into unix/epoch time. If you add ?long to the end of the variable you'll convert the datetime into epoch time (which is in seconds) then do math and convert it back to a date. Your example would be
${(triggerTimestamp?long - 1 * 1000 * 60 * 60)?number_to_datetime?string.iso}
In my inputFields of zapier, there's one field where the user can enter the date but I want the zapier to work only if I write the date in "2020-09-18T15:30" otherwise it should show a message that the data entered does not match the format specified. I tried this but it's not working.
const activityEditableFields = async (z, bundle) => {
if (bundle.inputData.dueDate) {
(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z/.test(`${bundle.inputData.dueDate}`))
}
here duedate in the field and I am giving the format that if there is data in it then it should match the specified format but there's no difference in the zap. If you can help me as soon as possible. Do reply.
This shouldn't be necessary. Per the docs:
DateTime fields let users enter dates and times, using their human readable values, machine readable datetimes, or standard English words for time like tomorrow. Zapier interperpates the date input from users and outputs a standard ISO 8601 datetime to your API.
If you declare the field as a datetime, then bundle.inputData.dueDate will always be a proper ISO 8601 datetime.
The easiest way I could find to workaround this issue was to use with JS code only the first 10 characters of the ISO8601 Zapier date.
bundle.inputData.dueDate.substr(0,10)
or to use moment to parse date (This library is supported by Zapier):
const moment = z.require('moment');
....
moment(bundle.inputData.dueDate).format("YYYY-MM-DD HH:MM:SS UTC")
The only drawback is that you need to use the code editor
${(.vars["OCRResponse"].Date)?datetime("ANY RANDOM FORMAT")?string("mm-dd-yy").
Can we use If Else within ?datetime, or can we resolve this by using switch case?
If that date format is quite "random", and you need to do this a lot, then you are probably better of writing a freemarker.core.TemplateDateFormat+TemplateDateFormatFactory implementation, do the complex date parsing logic in Java, then register the factory as a "custom date format" (that's a FreeMarker configuration setting), let's say with name "random". Then you can do ${OCRResponse.Date?date.#random?string('MM-dd-yy')}. If you set the date_format configuration setting to MM-dd-yy, then you can even just write ${OCRResponse.Date?date.#random}.
You can find concrete examples of defining a custom formats here: https://freemarker.apache.org/docs/pgui_config_custom_formats.html
Another possibility is to use #if/#elseif/#else of course. If you need to do that on multiple places, then put your parser logic into a #function, where you #return the parsed date. So where you insert a date you just have something like ${parseRandom(OCRResponse.Date)} (here I have assumed that date_format is MM-dd-yy, otherwise add ?string('MM-dd-yy')).
I need a hand here
The default OutSystems timezone is UTC
There's an Action called ConvertFromTimeZone(1,2,3)
1- You write the Date and Time, no problem here.
2 & 3 - You have to write the SourceTimeZone and the DestinationTimeZone, these must be written in Text data type.
My question is: How exactly am I supposed to write it?
Thanks.
you can use GetSystemTimeZones to get the list of available timezones in the servers.
This post http://www.outsystems.com/forums/discussion/16005/convertfromtimezone/#Post67485 shows the Identifier that uniquely identifiers a timezone.
Just one correction: the default timezone isn't UTC, but the timezone set in your application server.
The value you should use in the timezone code must be one of Microsoft Time Zone Index Values (column 'Name Of Time Zone')
You can find more information about timezone conversion here:
http://www.outsystems.com/forge/component-discussions/500/Time+Zone
you can use this action ConvertFromUTC(UTC_Datetime, "GMT Standard Time") it is from the Timezone extension.