Why is Time not setting when inserting new task using Task Service? - google-apps-script

I am trying to insert new task with due date and time in Google Tasks using Tasks Service. The issue i am facing is that date is setting correctly while time is not setting. The code is given below:
I had tried all the solutions given on stackoverflow and other platform, none of them worked.
var task = Tasks.newTask().setTitle(data[i]);
task.setDue("2019-6-25T10:10:10.000Z");
Tasks.Tasks.insert(task, taskList.id);
I expect both the date and time to be set but only date is setting.

The official document says as follows.
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.
Unfortunately, in the current stage, by above specification, even if 2019-6-25T10:10:10.000Z is used for due, it becomes 2019-06-25T00:00:00.000Z. So it seems that in order to modify the time, it is required to manually modify it.
Reference:
Resource representations of Tasks

Related

osisoft updating values ​with python

I want to get the data from Excel and update the values ​​of the data between certain dates in the osisoft system. But I don't know how to code AfTimeRange.
I get the error "value cannot be converted to OSIsoft.AF.Time.AFTime".
enter image description here
Good news: You've constructed your [AFTimeRange] correctly!
Notice that the error being thrown is not by the [AFTimeRange] constructor, but from something else.
The issue is that you are trying to set the 'Timestamp' attribute [OSIsoft.AF.Time.AFTime] to a value of type [OSIsoft.AF.Time.AFTimeRange], and so it's failing. A PI event has a single timestamp, not a time range.
I'm not familiar with Python, but it should work if you input the value as an AFTime object using its string constructor, assuming you're intending to use yesterday midnight as your timestamp:
val.timestamp = AFTime("y")
See the documentation on AFTime for more detail.

How to save Timestamp in Firebase in Appsmith app or using JSON?

I am trying to save the date/time in Firebase in timestamp format. I have referred answers from below posts.
How to get current timestamp of firebase server in milliseconds?
https://www.reddit.com/r/Firebase/comments/n32ys2/how_can_i_save_the_values_in_the_datepicker_as/
I have tried saving data by adding different date formats in Body but it is ultimately getting added as a string or number depending upon string or timestamp.
Does anyone have idea how to send the date to Firestore using JSON or anything using which i can directly add it to Appsmith app?
As of now Appsmith supports adding a server timestamp to any field in Firestore. Server timestamp is the timestamp provided by the Firestore server when that particular query was executed.
e.g. if there is entry like
{
id : {name: foo, lastUpdated: ts}
}
then the lastUpdated field could be updated with the last update timestamp via setting the Timestamp Value Path to ["id.lastUpdated"]
Please checkout the video here and comment by user tazmaniax to understand more: https://github.com/appsmithorg/appsmith/pull/3693
Reference:
https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldValue#serverTimestamp()
Appsmith's documentation for this is under progress and will be available on the Appsmith documentation site soon. Apologies for not putting it over there sooner.
For any other query or help please join Appsmith's discord channel
I have the impression that there is an error with the Firestore and Appsmith connector.
I have tried different combinations and if you do not send a string, int or bool in the json request, errors are generated.
However Appsmith added an additional field for handling timestamp (now)

Strange results returning from Response.getId() in GAS

I am working with a script to pull the response ID from a form submission so that when users edit their response, I can match the edit to the initial response. My script creates a .pdf of the contents of each form submitted, but when users edit responses, it creates a new form containing only the edited data, without linking it to the initial response.
The edit response contains a timestamp and the edited information, and the timestamp is used with Response.getId(timestamp), iirc, and returns the ID of the form submission. However, I am sometimes getting a very strange return, and I don't know where it comes from. The response is much shorter than a typical response ID (10-12 alphanumeric instead of 30+). I will try to comeback and edit this question with the code, but I'm on a different log in at the moment, so I'll have to swap over and copy code and come back. Running unit tests hasn't really helped, as I get the expected result most of the time. It's just an occasional hiccup, but I have to find where the incorrect information is coming from.
function getResponseId(timestamp){
var form = FormApp.openById('<formID>');
if(typeof(timestamp) != 'number'){
timestamp = new Date(timestamp);
}
var responses = form.getResponses(timestamp);
var entryId = responses[0].getId();
return entryId;
}
That's is. I suppose the if(typeof... may be throwing things off if it's passing in a Date string instead of the actual timestamp of entry, but I don't think so. I'll double check it and debug it in the meantime, and if I answer my own question, I'll come back and fix it.
Hmm. Sounds like the same behavior. What I decided to do instead was to match the timestamps that are recorded, but you have to grab the stamps in the 3rd line of code, as the old stamp is overwritten quickly. I just subtracted oldTime from newTime, left a 5 sec window to match them, and that worked. I just haven't had a chance to post it yet, as I just got it working for new submissions, edits, and failed writes about an hour ago.

EWS update changes time zone to UTC

I've seen this question asked several times on the web, but cannot find an answer.
When I create an appointment (meeting) using managed EWS 2.0, the invitation email correctly shows the time and time zone. When I update the meeting, the new invitation emails show the time in the UTC time zone. It is the correct time for UTC, but should display in Pacific.
I have tried setting the zone when creating the service connection, but this makes the initial invitation also show the time zone as UTC, as well as any updates.
I've tried setting the StartTimeZone and EndTimeZone properties, and have included those properties in the property set when binding the appointment for modification.
Is there another property somewhere that controls how Exchange formats the time when sending out the invitations? Here is some code showing how I am performing the updates:
Dim EWS As ExchangeService = GetEWSConnection(UserEmailAddress)
Dim meeting As Appointment = Appointment.Bind(EWS, New ItemId(CalendarEvent.ItemKey), New PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.ReminderDueBy, AppointmentSchema.StartTimeZone, AppointmentSchema.EndTimeZone, AppointmentSchema.TimeZone, AppointmentSchema.Subject, AppointmentSchema.Location, AppointmentSchema.Body))
Dim timeZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(LocalTimeZoneID)
With meeting
.Subject = CalendarEvent.Subject
.Location = CalendarEvent.Location
.Body = CalendarEvent.Body
.Start = CalendarEvent.StartTime
.End = CalendarEvent.EndTime
.StartTimeZone = timeZone
.EndTimeZone = timeZone
' snip (removed attendee add/remove)
.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToChangedAndSaveCopy)
End With
I realize that this is a frustrating answer, but I believe this to be an Exchange bug. No matter how you adjust the various time zone properties exposed by the API, this behavior still occurs. As far as I can tell, there aren't any server-level settings that would affect this either, although I admittedly haven't combed through all of them.
In my case, what seems to go along with the appended UTC time is that the message is changed from its original HTML to a plain text version upon update. That bug (http://support.microsoft.com/kb/2689810) has been fixed, but my organization hasn't applied the patch yet. It's possible, I suppose, that this bug was rendered obsolete when the other was fixed. If installing an update on your Exchange server is an option, then that might be worth a shot.

How to get hibernate to store a date?

I have a Spring / Hibernate project and I am trying to store a date into the database but it's not working. It must be something stupid but I have no idea what I am doing wrong.
Here is my code:
user.setFailedPasswordAnswerAttemptCount(0);
user.setLastLoginDate(new Date());
user.setIsOnline(true);
The other two variables (failedPasswordAnswerAttemptCount and isOnline) are getting written to the database without issue. I have also tried it with just passing a java.util.Date instead of a java.sql.Timestamp...same result. Here is how the property is defined on the user object:
private Date lastLoginDate;
#Temporal(TemporalType.TIMESTAMP)
#Column(name="last_login_date")
public Date getLastLoginDate() {
return this.lastLoginDate;
}
public void setLastLoginDate(Date lastLoginDate) {
this.lastLoginDate = lastLoginDate;
}
Here is the column definition:
`last_login_date` datetime DEFAULT NULL
Any help? I don't even know what else to look for as this should be working.
Some more detail about the error: No errors or strange messages in the hibernate log. The hibernate log is showing a parameterized query but it isn't telling me what it is actually writing. It looks like it's not updating the column at all. In other words, if there is already a date there it doesn't change, or if it is null it doesn't change.
Update: I have looked at the logs and it looks like hibernate does write the proper data, but then immediately writes the incorrect data again. I see the following entry in the log:
11:15:12.280 [http-bio-8080-exec-26] TRACE o.h.e.def.AbstractSaveEventListener - detached instance of: com.hi.model.User
11:15:12.280 [http-bio-8080-exec-26] TRACE o.h.e.def.DefaultMergeEventListener - merging detached instance
And right after that I see it putting the old value back in for the lastLoginDate.
Why are you using
Date date = new Date();
user.setLastLoginDate(new Timestamp(date.getTime()));
and not just this?
user.setLastLoginDate(new Date());
First - You may not want to use Date and Timestamp at the same time.(e.g. for collections, etc)
There are some classes in the Java platform libraries that do extend an instantiable
class and add a value component. For example, java.sql.Timestamp
extends java.util.Date and adds a nanoseconds field. The equals implementation
for Timestamp does violate symmetry and can cause erratic behavior if
Timestamp and Date objects are used in the same collection or are otherwise intermixed.
The Timestamp class has a disclaimer cautioning programmers against
mixing dates and timestamps. While you won’t get into trouble as long as you
keep them separate, there’s nothing to prevent you from mixing them, and the
resulting errors can be hard to debug. This behavior of the Timestamp class was a
mistake and should not be emulated. (Bloch, Effective Java, 2nd Ed.)
Second - I checked your examples, and it works fine for me on mysql-connector(5.1.21) / hibernate (4.0.1)
I prepared simple test project with arquillian integration test(You need to prepare jboss before running it):
https://github.com/rchukh/StackOverflowTests/tree/master/13803848
If you can provide some more information it might help - hibernate version, mysql version, mysql engine(MyISAM, InnoDB, etc.)
Otherwise it is possible that this is just a misconfiguration.
I found the problem. I am refactoring some code and it looks like I was doing this:
//get user object
User user = getUser();
//call a function which modifies user
functionModifiesUser();
//modify user
user.blah = blah;
entityManager.merge(user);
So the parent function had a stale copy of the user object when I tried to save it. Actually, removing the merge statement was enough to fix it. But I have refactored the code to put all this in one place.
Setting the column last_login_date as timestamp should work, at least works for me.