The custom date works in RMarkdown-pdf but I noticed Quarto doesn't.
How can I use custom date in Quarto YAML?
---
title: "Some pdf document"
author: "me"
date: "Spring 2022" <- I would like to use this
format: pdf
----
---
title: "Some pdf document"
author: "me"
date: "Last update : `r Sys.Date()`" <- Or, like this
format: pdf
----
Current Quarto-pdf generates %m/%d/%Y format date only.
You can provide last-modified keyword (which refers to the last modified date and time of the file containing the date) to date and use date-format to modify the date. Also you can put additional words in between square brackets which will be then escaped and kept as is.
---
title: "Some pdf document"
author: "me"
date: last-modified
date-format: "[Last Updated on] MMMM, YYYY"
format: pdf
---
Now, since there is no format-string for season name, it is possible make one using Pandoc Lua filter.
---
title: "Some pdf document"
author: "None"
date: last-modified
date-format: "[Last Updated on] %MMM%, YYYY"
format: pdf
filters:
- custom-date.lua
---
Note Here we have used %MMM%, which will be replaced by season name.
custom-date.lua
local function replace_mon_with_season(date)
local season_table = {
Jan = "Winter", Feb = "Winter", Mar = "Spring",
Apr = "Spring", May = "Spring", Jun = "Summer",
Jul = "Summer", Aug = "Summer", Sep = "Autumn",
Oct = "Autumn", Nov = "Autumn", Dec = "Spring"
}
local date = pandoc.utils.stringify(date)
local mon = date:match("%%(%a+)%%")
local season = season_table[mon]
return date:gsub("%%" .. mon .. "%%", season)
end
function Meta(m)
m.date = replace_mon_with_season(m.date)
return m
end
Related
So I am trying to convert a Unix Timestamp into a Human Readable date format (ex: January 20, 2021).
This is the response that I get from an API which gives the Unix timestamp
"time":1388620296020
And then I try to transform it using the Transform Message, my code looks like this
date: (object.properties.time as DateTime) as String {
format: "MMMM dd, yyyy"
},
But the output I get after I deploy it, goes like this
"date": "August 17, +45973"
I am not sure why is it happening.
Epoch can be directly converted to DateTime in Dataweave
Try This
date: (object.properties.time as DateTime {unit : "milliseconds"})
output:
"date": "2014-01-01T23:51:36.02Z"
You can check the output by entering in the below link as well
https://www.unixtimestamp.com/
https://www.epochconverter.com/
Another way to get the exact format,that you mentioned in the quesion (ex: January 20, 2021) it is achievable by below script
%dw 2.0
output application/json
---
date: payload.message as DateTime {unit : "milliseconds"}
as String {format: 'MMMM dd,yyyy'}
this script will give you output as:
{
"date": "January 01,2014"
}
Convert Unix Timestamp to Date Time in Mule 4
Input :
{
"time":1388620296020
}
---------output----------
{
"date": "01-Jan-2014 11:51:36"
}
How to write the script, You understand correct format Date Time.
%dw 2.0
output application/json
{
date: payload.time as DateTime {unit: "milliseconds"} as String {format: 'dd-MMM-yyyy hh:mm:ss'}
}
For more info referred link : https://help.mulesoft.com/s/question/0D52T00004tIkcf/how-to-convert-unix-timestamp-to-normal-human-readable-timestamp-using-dw-20
Thanks
In my case I have setup the timeline like:
events: [{
title: 'My schedule'
start: '2021-07-08T01:00:00Z',
end: '2021-07-08T03:00:00Z',
}]
Which mean that my time 00:00UTC will be shifted to local time GMT+7 and timeZone:'local' (as default) , follow as this doc https://fullcalendar.io/docs/date-parsing
At ui view is render timeline exactly what I want that 2021-07-08T08:00:00Z GMT+7 & 2021-07-08T10:00:00Z GMT+7 (Perfect).
But when I try to get back that info with:
eventMouseEnter(info) {
console.log(info.event._instance.range);
}
I get this:
{
end: Wed Jul 08 2021 15:08:10 GMT+0700 (Indochina Time) {}
start: Wed Jul 08 2021 17:08:10 GMT+0700 (Indochina Time) {}
}
Don't know why but, is seem like i get the wrong info or that info just add more GMT+7?
Thanks
I am writing a script in python to create an event.Newbie at this.Below is the entire script code for reference.
import requests,json
from datetime import datetime
event={}
event['name']={}
print("Enter the following:\ntitle of event")
event['name']['html']=input()
event['description']={}
event['description']['html']=input("Event description:\n")
event['start']={}
startdate=datetime.strptime(input("start datetime eg :Jun 1 2005 1:33PM :\n"),'%b %d %Y %I:%M%p')
event['start']['utc']=str(startdate.date())+'T'+str(startdate.time())+'Z'
#event['start']['utc']=startdate.isoformat()+"Z"
#Turning datetime in YYYY-MM-DDThh:mm:ssZ format
event['start']['timezone']=input("timezone eg Asia/kolkata\n")
event['end']={}
enddate=datetime.strptime(input("end datetime eg :Jun 1 2005 1:33PM\n"),'%b %d %Y %I:%M%p')
event['end']['utc']=str(enddate.date())+'T'+str(enddate.time())+'Z'
#event['end']['utc']=enddate.isoformat()+"Z"
event['end']['timezone']=event['start']['timezone']
event['currency']=input("3 letter code")
response = requests.post("https://www.eventbriteapi.com/v3/events/",
headers = {
"Authorization": "Bearer NC.....",
"Content-Type" : "application/json"
},
data=json.dumps({"event":event}),
verify = True, # Verify SSL certificate
)
Strictly followed the docs https://www.eventbrite.com/developer/v3/endpoints/events/
According to docs datatype of event.start.utc and event.start.end data shall be datetime i.e "2010-01-31T13:00:00Z"
We can see in the comments I also tried with isoformat function.
On printing event object I found the same format as specified in the docs.
But receiving response.content as event.start invalid argument or event.start.utc as datetime wrong format use instead "YYYY-MM-DDThh:mm:ssZ" !!
I ran into date issues with Eventbrite too; after debugging found this to work for events:
{ event:
{ name: { html: 'Postman API Event!' },
description:
{ html: 'My fav event is The Winter Formal.' },
start: { timezone: 'America/Los_Angeles', utc: '2018-09-06T00:19:53Z' },
currency: 'USD',
listed: false,
end: { timezone: 'America/Los_Angeles', utc: '2018-09-06T00:20:53Z' } } }
and of course, different date formats in another part of API ;-)
Regarding discounts / cross event discount, where the docs specify a
Naive Local ISO8601 date and time format
First I've heard of the 'Naive' format? Why no example Eventbrite? Here's what worked:
2018-10-11T12:13:14
So I'm using datatables and their moment.js plugin (https://datatables.net/plug-ins/dataRender/datetime). I always get (the string) "Invalid date" returned...
{ "data": "last_updated", //source: 2016-11-02 10:32pm GMT
render: $.fn.dataTable.render.moment( 'YY-MM-DD hh:mmtt GMT', 'DD MMM YY' )
}
Thanks!
That plugin takes one, two or three arguments. From testing it seems as though your date is valid so I'd suggest just passing "SS MMM YY" to the function. As a quick example this seems to work:
moment("2016-11-02 10:32pm GMT").format("DD MMM YY"); // "02 Nov 16"
Another issue might be that the date isn't set, so it's perhaps worth checking for nulls and setting some default content. In fact, if you've already got momentjs available you can replace the plugin with this as the render function:
"render": function(data){
return (moment(data).isValid()) ? moment(data).format("DD MMM YY") : "-";
}
Hope that helps.
cat input.txt | awk '/ID/;/TimeReceived/ {print $2,$3,$4}'
Output:
ID: f7a570c2
03/26/14 18:22:50 GMT
ID: f7f810a2
08/13/14 23:50:59 GMT
ID: f8e76dd2
04/25/14 06:13:10 GMT
ID: f92e90c2
03/19/14 12:51:23 GMT
ID: f98ac152
08/01/14 00:10:43 GMT
ID: faef4812
04/21/14 16:29:15 GMT
ID: fb6b38d4
05/06/14 17:32:20 GMT
ID: fbfb0d92
08/26/14 04:24:07 GMT
ID: fc15d932
05/27/14 18:44:48 GMT
ID: fc235e12
06/03/14 12:39:17 GMT
ID: fc988622
06/23/14 16:02:29 GMT
ID: fcb1e6c2
03/25/14 17:37:48 GMT
ID: fd025382
05/28/14 16:50:29 GMT
ID: fd061b12
04/21/14 18:41:41 GMT
ID: fd7efde2
08/15/14 18:01:27 GMT
ID: fdd30022
05/28/14 15:51:29 GMT
ID: fdf73792
03/31/14 20:13:00 GMT
ID: fe9d3a22
04/15/14 16:15:37 GMT
ID: fea03cf2
08/04/14 02:06:00 GMT
ID: ff7e3de2
07/07/14 10:51:41 GMT
The above output isn't sorted based on time. I want to extract all the "ID" which has the created time should be olderthan a month . can some one help me to code it ?
With GNU awk and GNU date the following should work:
awk -vcutoff="$(date -d"-1 month" +%s)" '
/^ID:/ {
ID=$2
next
}
/^TimeReceived:/ {
split($2, d, /\//)
gsub(/:/, " ", $3)
tm=mktime("20"d[3]" "d[1]" "d[2]" "$3)
if (tm<cutoff) {
print ID
}
}' input
As per discussion in the comments some examples of how date does its calculations:
$ date -d "03/31/2014 - 1 month"
Mon Mar 3 00:00:00 EST 2014
$ date -d "06/26/2014 - 1 month"
Mon May 26 00:00:00 EDT 2014
The info page for date has a little more information about these calculations in section 28.6 Relative items in date strings.