"Timezone less events" migration for Facebook - facebook

Facebook recently added timezone less events (https://developers.facebook.com/roadmap/#timezone-less-events) to its Developer roadmap which says
"Since this migration was originally created, we have added a timezone field to events which indicates the name of the timezone (as defined here) where the event is expected to happen. FYI, developers reading time in ISO 8601 should be supporting the full standard when reading event times. Most events return local times (no GMT offset), but in the future events likely will return other formats (namely date-only and precise)."
It works for dates in ISO 8601 format but if I get dates in epoch format I always get +7 hrs difference.
e.g.
https://graph.facebook.com/369000383135224 returns
{
"id": "369000383135224",
"owner": {
"name": "Horst Uwe Peter",
"id": "1117563687"
},
"name": "Event in Dublin time 10:25",
"start_time": "2012-05-04T10:25:00",
"end_time": "2012-05-04T11:25:00",
"timezone": "Europe/Dublin",
"location": "Dublin, Ireland",
"venue": {
"id": "110769888951990"
},
"privacy": "FRIENDS",
"updated_time": "2012-05-04T09:27:29+0000",
"type": "event"
}
and
http://graph.facebook.com/369000383135224?date_format=U returns
{
"id": "369000383135224",
"owner": {
"name": "Horst Uwe Peter",
"id": "1117563687"
},
"name": "Event in Dublin time 10:25",
"start_time": 1336152300, <== Fri, 04 May 2012 17:25:00 GMT
"end_time": 1336155900, <== Fri, 04 May 2012 18:25:00 GMT
"timezone": "Europe/Dublin",
"location": "Dublin, Ireland",
"venue": {
"id": "110769888951990"
},
"privacy": "FRIENDS",
"updated_time": 1336123649,
"type": "event"
}
and with FQL using GRAPH end point
graph.facebook.com/fql?q=SELECT eid, name, description, location, venue, start_time, end_time, update_time, creator, privacy FROM event WHERE eid = 369000383135224
{
"data": [
{
"eid": 369000383135224,
"name": "Event in Dublin time 10:25",
"description": "",
"location": "Dublin, Ireland",
"venue": {
"id": 110769888951990
},
"start_time": 1336152300, <== Fri, 04 May 2012 18:25:00 GMT
"end_time": 1336155900, <== Fri, 04 May 2012 18:25:00 GMT
"update_time": 1336123649,
"creator": 1117563687,
"privacy": "FRIENDS"
}
]
}
does that mean migration works only for ISO 8601 formatted dates? and has no affect on FQL or epoch date format?

My events on a page I administer have never returned a timezone.
What I have found is that event times entered in the frontend dialog are treated as local times in "America/Los_Angeles" (complete with the US Daylight Savings Time changes, so you'll see +6 in winter and +7 in summer) and are then converted to "UTC" for storage in the database.
For display I use the following php function to show the correct times and note on the page that the times are local to the event's location:
function fb_event_time_convert($fb_time) {
$origin_dtz = new DateTimeZone('UTC');
$remote_dtz = new DateTimeZone('America/Los_Angeles');
$fb_time_str = '#' . $fb_time;
$origin_dt = new DateTime($fb_time_str, $origin_dtz);
$remote_dt = new DateTime($fb_time_str, $remote_dtz);
$offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt);
return $fb_time - $offset;
}

Related

Google task api due field

I am using google task list api and getting list from server. I created three task with different due time and date. I am getting date for every task but getting same due time. Can you please elaborate why this is happening?
Output:
{
"kind": "tasks#tasks",
"etag": "*********",
"items": [
{
"kind": "tasks#task",
"id": "******",
"etag": "******",
"title": "Task 2",
"updated": "2021-01-29T14:40:36.000Z",
"selfLink": "******",
"position": "00000000000000000001",
"status": "needsAction",
"due": "2021-01-30T00:00:00.000Z"
},
{
"kind": "tasks#task",
"id": "*********",
"etag": "*******",
"title": "Task 4",
"updated": "2021-01-29T13:18:51.000Z",
"selfLink": "*******",
"position": "00000000000000000000",
"status": "needsAction",
"due": "2021-01-30T00:00:00.000Z"
},
{
"kind": "tasks#task",
"id": "***********",
"etag": "*************",
"title": "Task 1",
"updated": "2021-01-29T13:08:39.000Z",
"selfLink": "*******",
"position": "00000000000000000002",
"status": "needsAction",
"due": "2021-01-29T00:00:00.000Z"
}
]
}
Based on the Resource:tasks,
Field: due
Due date of the task (as a RFC 3339 timestamp). Optional. The due date only records date information; the time portion of the timestamp is discarded when setting the due date. It isn't possible to read or write the time that a task is due via the API.
Google api can only read date not time for due field.
This line is from their official documentation Tasks API . tasks
Blockquote
"due": "A String", # Due date of the task (as a RFC 3339 timestamp). Optional. The due date only records date information; the time portion of the timestamp is discarded when setting the due date. It isn't possible to read or write the time that a task is due via the API.

Add day to a date in Vega-Lite

I'm trying to add a day to my dates which look like "2020-11-20" for November, 20, 2020. However I am encountering difficulty doing that - do I need to use the offset function? The reason I am doing this is that Vega-Lite is automatically offsetting my dates back 1 day through its GMT conversion and I cannot get it to stop. Please help!
Here is an example. If you look at the timeline graph it ends at 2020-11-19, but the final date in my data is 2020-11-20, and I need to make it so 2020-11-20 is the last date on my timeline graph.
This issue comes from an unfortunate "feature" of how javascript parses dates. Here is a minimal example of the problem you're seeing (open in editor):
{
"data": {
"values": [
{"date": "2020-11-17", "value": 5},
{"date": "2020-11-18", "value": 6},
{"date": "2020-11-19", "value": 7},
{"date": "2020-11-20", "value": 8}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "value", "type": "quantitative"},
"y": {
"field": "date",
"timeUnit": "yearmonthdate",
"type": "ordinal"
},
"tooltip": [
{
"field": "date",
"timeUnit": "yearmonthdate",
"type": "temporal"
}
]
}
}
Each of the days in the chart are off by one compared to the input. So why is this happening?
Well, it turns out that the Vega-Lite's renderer makes use of Javascript's built-in date parsing, and Javascript's date parsing treats inputs differently depending on how they're formatted. In particular, Javascript will parse non-standard timestamps in UTC time, but will parse full ISO-8601 timestamps in local time, a fact you can confirm in your browser's javascript console (I executed this on a computer set to PST):
> new Date('2020-11-20')
Thu Nov 19 2020 16:00:00 GMT-0800 (Pacific Standard Time)
> new Date('2020-11-20T00:00:00')
Fri Nov 20 2020 00:00:00 GMT-0800 (Pacific Standard Time)
The Vega-Lite docs recommend using UTC timeUnits and scales to work around this, but I tend to find that approach a bit clunky. Instead, I try to always specify dates in Vega-Lite via full ISO 8601 timestamps.
In your case, the best approach is probably to use a calculate transform to regularize your dates, and proceed from there. Modifying the simplified example above, it might look something like this (open in editor):
{
"data": {
"values": [
{"date": "2020-11-17", "value": 5},
{"date": "2020-11-18", "value": 6},
{"date": "2020-11-19", "value": 7},
{"date": "2020-11-20", "value": 8}
]
},
"transform": [
{"calculate": "toDate(datum.date + 'T00:00:00')", "as": "date"}
],
"mark": "bar",
"encoding": {
"x": {"field": "value", "type": "quantitative"},
"y": {
"field": "date",
"timeUnit": "yearmonthdate",
"type": "ordinal"
},
"tooltip": [
{
"field": "date",
"timeUnit": "yearmonthdate",
"type": "temporal"
}
]
}
}

Inserting a birthdate with Date in NoSql

I am trying to insert a birthday with Date type in NoSQL like this
db.employees.insertOne({
"Name": "Alison Davison",
birthday: Date("Apr 05, 1975"),
"Address": "874 W. Oak Place",
"City": "Gary",
"State": "Indiana",
Position:{Name: "Customer Support", Remote: true, Full Time: true}
});
And is throwing this error
uncaught exception: SyntaxError: missing : after property id :
#(shell):7:63
You need to use the supported format in the Date constructor.
new Date("<YYYY-mm-dd>") returns the ISODate with the specified date.
new Date("<YYYY-mm-ddTHH:MM:ss>") specifies the datetime in the client’s local timezone and returns the ISODate with the specified datetime in UTC.
new Date("<YYYY-mm-ddTHH:MM:ssZ>") specifies the datetime in UTC and returns the ISODate with the specified datetime in UTC.
new Date(<integer>) specifies the datetime as milliseconds since the Unix epoch (Jan 1, 1970), and returns the resulting ISODate instance.
The format you tried is not supported default.
Refer
And please use the below. You have a space in your key. Enclose it with quotes.
{
"Name": "Alison Davison",
"birthday": new Date("1975-04-05"),
"Address": "874 W. Oak Place",
"City": "Gary",
"State": "Indiana",
"Position": {
"Name": "Customer Support",
"Remote": true,
"Full Time": true
}
}

gSuite Integeration Admin SDK Report API Date format

Hi Guys I am currently working on Gsuite Admin SDK Report API. I am successfully able to send the request and getting the response.
Now, the issue is that I am not able to identify the date format returned by the Activities.list().
Here is a snippet:
"events": [
{
"type": "event_change",
"name": "create_event",
"parameters": [
{
"name": "event_id",
"value": "jdlvhwrouwovhuwhovvwuvhw"
},
{
"name": "organizer_calendar_id",
"value": "abc#xyz.com"
},
{
"name": "calendar_id",
"value": "abc#xyz.com"
},
{
"name": "target_calendar_id",
"value": "abc#xyz.com"
},
{
"name": "event_title",
"value": "test event 3"
},
{
"name": "start_time",
"intValue": "63689520600"
},
{
"name": "end_time",
"intValue": "63689524200"
},
{
"name": "user_agent",
"value": "Mozilla/5.0"
}
]
}
]
Note: Please have a look at start_time and end_time and let me know if you guys have any idea about it.
Please have a look and share some info and let me know if any other infomation is needed.
I ran into this same question when parsing google calendar logs.
The time format they use are the number of seconds since January 1st, 0001 (0001-01-01).
I never found documentation where they referenced that time format. Google uses this instead of epoch for some of their app logs.
You can find an online calculator here https://www.epochconverter.com/seconds-days-since-y0
Use the one under "Seconds Since 0001-01-01 AD" and not the one under year zero.
So your start_time of "63689520600" converts to March 30, 2019 5:30:00 AM GMT.
If you want start_time to be in epoch, you could subtract 62135596800 seconds from the number. 62135596800 converts to January 1, 1970 12:00:00 AM when counting the number of seconds since 0001-01-01. Subtracting 62135596800 from the start_time would give you the number of seconds since January 1, 1970 12:00:00 AM AKA Epoch Time.
Hope this helps.

Azure Data Factory copy day before data from slicestart date

can somebody let me know how to get previous days data i.e 2017-07-28 etc from my onpremises file system if my pipleline start and end dates are
"start": "2017-07-29T00:00:00Z",
"end": "2017-08-03T00:00:00Z"
My pipeline's input is"FileSystemSource" and output is "AzureDataLakeStore". I have tried below JSON in my copy pipeline as input
"inputs": [
{
"name": "OnPremisesFileInput2"
"startTime": "Date.AddDays(SliceStart, -1)",
"endTime": "Date.AddDays(SliceEnd, -1)"
}
]
I have also tried defining "offset" in the input and output datasets and in the pipeline as follows
"availability": {
"frequency": "Day",
"interval": 1,
"offset": "-1.00:00:00",
"style": "StartOfInterval"
},
"scheduler": {
"frequency": "Day",
"interval": 1,
"offset": "-1.00:00:00",
"style": "StartOfInterval"
},
none of the above seems to be working. Request someone to help me.
I think a good strategy to do this is to think about yesterday's output as today's input. Azure Data Factory let's you run activities one after another in sequence using different data sources.
There's good documentation here
With an example like this:
Like this you can either have a temporary storage in between the two activities or use your main input data source but with a filter to get only yesterday's slice.
Your offset should be positive.
"availability": {
"frequency": "Day",
"interval": 1,
"offset": "01:00:00",
"style": "EndOfInterval"
}
In this case it will run for example on September 7th at 1:00 AM UTC and will run the slice from Sep 6th 0:00 UTC to Sept 7th UTC. Which is yesterday slice.
Your input dataset should be configured to use the SliceStart for the naming of the file
"partitionedBy": [
{
"name": "Slice",
"value": {
"type": "DateTime",
"date": SliceStart",
"format": "yyyymmdd"
}
}],
"typeProperties": {
"fileName": "{slice}.csv",
}
It would look for 20170906.csv file when executed on Sept 7th.