How to save Timestamp in Firebase in Appsmith app or using JSON? - 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)

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.

Why is Time not setting when inserting new task using Task Service?

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

AngularJS deserialize $http JSON dates i18n

I have a problem and I don't quite know how to deal with it. It must be a common problem, but I didn't find a good answer yet.
I'm coding a MEAN stack app, using Mongoose, and the problem I have is with the dates format when changing the language in my app.
The scenario is: The user can insert some data that has a Date field, for example their birthday. That field is then sent to mongoose in a specific format (yyyy-MM-dd) and it gets stored correctly in a Date field in mongoose. When the user searches for the data stored, I have an $http get request that get back the data in JSON format. Right before the data is send from the server, I have this in the JSON:
{datetime: '2015-11-13T20:00:00.000Z'}
And send it from nodejs like this:
return res.status(201).send(obj);
And when the Angular gets it, depending on the language I'm using in that moment, it resolves to a Date or an Invalid date. If the language I'm using is English, the resulting JSON has a valid Date in that field. If I change it to Spanish for example, then it results into an Invalid date field.
The code in Angular is this:
$http.get(url).then(function (result) {
//here the result.data may have an Invalid Date field
deferred.resolve(result.data);
}, function (error) {
deferred.reject(error);
});
I set the language in my app with the help of angular-translate, and I use angular-i18n and momentjs also.
I've read on this and here https://docs.angularjs.org/api/ng/service/$http it say that
If JSON response is detected, deserialize it using a JSON parser.
I understand that the default parser detects the Spanish i18n and tries to parse the date as yyyy-dd-MM, and obviously gets an Invalid Date.
The question here is: How can I explicitly set all the dates parsed in Angular, to follow a specific format, like yyyy-MM-dd, regardless of the i18n used? I've seen this solution already, but doesn't work for me: http://aboutcode.net/2013/07/27/json-date-parsing-angularjs.html
Is there a better way to handle all this? Maybe store the dates in Mongo not as Date fields, but like Strings, using the JS getTime() function?
This last method means that I would have to change all the dates in my app. It's a lot more work, but the result will be more standard, right?
Thank you!

How to deserialize asp.net datetime as JSON datetime with client's timezone

I'm struggling with datetimes a bit. I'm using asp.net mvc api controllers, a microsoft sql server and AngularJS.
On some button click I'm sending a JSON formatted date to an api-controller. When I post 2015-11-31 00:00 and I look in Fiddler to see what's really posted, I see that the date is formatted as such: 2015-11-30T23:00:00.000Z. (2015-11-31 - 1 hour UTC+01:00 Amsterdam, Berlin, Ber....) This is perfect because there might be a difference between the timezone the sql server might be in and the client. (Or is it?)
The problem is though: When I get the date back from the sql server it doesn't take the client's time zone into account. When I read the DateTime object from the sql server and I return it JSON formatted, the date that's being displayed is: 2015-11-30T23:00:00.000Z. I want it to add 1 hour to be in the timezone where the client is.
My question is: What do I do to get it to keep the timezone in to account while deserializing the JSON string that comes back from my api-controller?
TIA!
Problem turns out to be that when the object is being deserialized, the date property is not of type DateTime. It is of type string. Simply converting it to date by using new Date("2015-11-30T23:00:00.000Z") will do the trick.
I made filter for it:
.filter('from_gmt_to_local_date', [function () {
return function (text) {
return new Date(text);
};
}])
Usage:
{{contract.StartDate | from_gmt_to_local_date | date:'dd-MM-yyyy'}}
Hope this helps anybody.

Spring roo not recognizing date format before saving json

I'm using Spring Roo on top of MySQL. I pull dates out via the Roo-generated JSON methods, make changes to that data in a browser form, and save it back via the Roo-generated JSON methods.
The date format I'm getting out is yyyy-MM-dd, standard MySQL date format. I'm using a calendaring widget on the browser to ensure the date I'm submitting is the same format.
Unfortunately my data doesn't go right through the ...FromJson() method, failing with the error:
Parsing date 2007-12-12 was not recognized as a date format
I presume that the problem is that it's coming out as a string, but JPA feels like it needs to generate a Date object to update.
I'll happily show my code about this, but it's nothing Roo didn't build for me.
It occurs to me that there's something it's referring to when it says "recognized as a date format". Is there somewhere I can change what date formats it knows?
EDIT: With #nowaq's help, here's the ultimate answer:
public static Lease fromJsonToLease(String json) {
return new JSONDeserializer<Lease>()
.use(null, Lease.class)
.use(Date.class, new DateFormatter("yyyy-MM-dd"))
.deserialize(json);
}
That way JSONDeserializer knows what class it's dealing with AND builds a formatter for all the dates in that class. Wicked!
Your question is very related to this one: Spring-roo REST JSON controllers mangle date fields Take a look and make sure you're using correct DateTrasformer(s) with your JSON deserializers. E.g.
new JSONDeserializer()
.use(Date.class, new DateTransformer("yyyy-MM-dd") )
.deserialize( people );