How to get Date Added to Health in Healthkit - healthkit

I do not know how can i get the "Date Added to Health" ? I can not find some info about the "Date Added to Health" from HKSample.
Anyone can help me ?
HKSample : HKObject
open var sampleType: HKSampleType
open var startDate: Date
open var endDate: Date
Only has startDate & endDate, no has "Date Added to Health"

There is no API in HealthKit to get the date a sample was added to Health. You should file a bug with Apple if you'd like this feature to be added.

Related

Mongodb query Dates returning as String of numbers

for my MEAN stack project I have to store a Date object in MongoDB for the start and end of a booking. the Date goes in just fine, in my collection it's show as:
booking_start: 2022-12-16T00:00:00.000+00:00
booking_end: 2022-12-29T00:00:00.000+00:00
but when i query my collection for all entries the Dates come out as strings of numbers like this
"booking_start": "1671148800000",
"booking_end": "1672272000000"
what is going on here? I'll admit I'm new to working with Dates in Mongo but why is happening? I am using Graphql for my queries, but i don't think that the problem. is there a special way to query a Date?
here is my code and queries
resolver
getuserbooking: async ()=>{
const userListinglist = userbooking.find({})
return userListinglist
}
it's schema
type Query {
getuserbooking:[userbooking]
}
and it's mongoose model
booking_date:{
type: Date,
default: Date.now,
required:[true,"Please enter booking date"],
},
booking_start:{
type: Date,
required:[true,"Please enter booking start"],
},
booking_end:{
type: Date,
required:[true,"Please enter booking end"]
Please any help would be greatly appreciated
okay i figured out what went wrong, the numbers i kept getting back was a timestamp. i had to convert the timestamp into a Date so it could be displayed in the front end properly. if anyone else is having trouble with this here: https://bobbyhadz.com/blog/javascript-convert-milliseconds-to-date
hint: if your timestamp is a string use parseInt()

How to change date format in Google Forms Response?

I have a Google Forms to get my delivery order from customer and on the forms I have Date field.
The response of the forms will be filled automatically to order document per response.
I use this scripts:
function autoFill(e) {
var timestamp = e.values[0];
var nama = e.values[1];
var tglBuat = e.values[10];
var file = DriveApp.getFileById(MY_TEMPLATE_FILE_ID);
var folder = DriveApp.getFolderById(OUTPUT_FOLDER_ID);
var copy = file.makeCopy(nama+"_"+timestamp, folder);
var doc = DocumentApp.openById(copy.getId());
var body = doc.getBody();
body.replaceText('#NamaLengkap#', tglBuat);
body.replaceText('#TanggalDibuat#', tglBuat);
doc.saveAndClose();
}
The flow is simple like this:
I prepared Template file for the Order Document paper
Customer will fill the forms
Form result will be kept in certain Google Spreadsheet
The script above on the (3), will be triggered everytime (2) submitted
Voila, I have Order Document filled with customer order details
My template file are something like this:
Customer Name: #NamaLengkap#
Order Date: #TanggalDibuat#
My problem is here in date format, I want the output on my template file using this format "26 August 2020", but the google form only give this format "08/26/2020".
How do I changes it?
I read some article about changing the email format before filling the form, but i don't think this is good solution. Because customer wont care at all.
Solution
You just need to take your date and convert it to a Date String Javascript object as shown below:
function myFunction() {
var shortDate = new Date("03/25/2015");
var longDateFormat = shortDate.toDateString();
Logger.log(longDateFormat);
}
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)

Fullcalendar sets all events one day back

I call the fullCalendar method as follows:
<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
firstDay: 1,
eventLimit: true, // allow "more" link when too many events
events: [{title":"Matthias Klein","start":"01-01-2014","end":"01-01-2015"},{"title":"Matthias Klein","start":"01-01-2014","end":"02-01-2014"},{"title":"Matthias Klein","start":"01-01-2014","end":"01-01-2014"}]
});
});
But in the result all events starting and ending one day before at 2:46a:
see Image
What do I do wrong?
Few things,
Try changing your date format for your events to yyyy-mm-dd I had this issue last night where my events were all showing at 4;30pm the day before and this fixed it for me.
Also noticed your dates have no times so are they all day events? If so make sure you're setting the allDay property to true.
One last thing, firstDay means the day of the week, so if Monday is 0 then Tuesday is 1. It doesn't mean the first day of the month.
I had the same problem and was only able to solve it by following the EXACT date format given on the demo page...
yyyy-MM-ddTHH:mm:ss (for example 2019-05-08T16:00:00 is 4 o'clock today)
or
yyyy-MM-dd (for example 2019-05-08 is today)
In other words, U.S. date format plus 24-hour time format.
Unfortunately there does seem to be a bug with nextDayThreshold. If it's set to 00:00:00 (the default), events ending at this time will be displayed as having ended the day before, which contradicts the documentation. Also, allDay=true events spanning more than one day will always be displayed as ending on the previous day.
Here's my full code...
addEvents = [];
addEvents.push({
title: "First Event",
url: "http://localhost:11634/events/141",
start: '2019-05-19T09:00:00',
end: '2019-05-19T13:00:00'});
addEvents.push({
title: "Second Event",
url: "http://localhost:11634/events/137",
start: '2019-11-02',
end: '2019-11-02'});
addEvents.push({
title: "Third, multi-day event",
url: "http://localhost:11634/events/115",
start: '2019-11-08T00:00:00',
end: '2019-11-10T01:00:00'});
document.addEventListener('DOMContentLoaded', function () {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: ['dayGrid'],
events: addEvents
});
calendar.render();
});
Another way to fix that: use nextDayThreshold parameter
$('#calendar').fullCalendar({
**nextDayThreshold**: '00:00:00', // 9am
nextDayThreshold set the minimum time it must be in order for it to render as if it were on that day.
I saw this issue and in my application it appears to be a timezone problem. When making the round trip to by database and back, the Date object appears to pick up timezone information, which screws up the calendar...

Change IETF format to unix timestamp

Hi is there a way to change the time format for the following snipp in fullcalendar?
select: function(startDate, endDate) {
$.fancybox({
\'width\': \'40%\',
\'height\': \'40%\',
\'autoScale\': true,
\'transitionIn\': \'fade\',
\'transitionOut\': \'fade\',
\'type\': \'iframe\',
\'href\': \'test.php/?start=\'+startDate+\'&end=\'+endDate,
});
calendar.fullCalendar(\'unselect\');
}
I want Start & EndDate to be a unix Timestamp.
Thank You
It can be achieved by overriding the "start" and "end" parameter by sending separating Ajax Request inside the FullCalendar.
Take a look at this Similar Thread: add custom params to fullcalendar request

How to switch to a particular week in a FullCalendar jQuery plugin

I would like to switch to a particular week when a User selects any date.
On selection of the date the full calendar will display the agenda week in which the week resides.
Please suggest how to do it.
Thanks
Prabhanjan
This should work, but I haven't tested it yet. Let me know how it goes...
dayClick: function(date){
$("#calendar").fullCalendar('changeView', 'agendaWeek')
.fullCalendar('gotoDate', date);
}
And if your using select there is a problem when trying to use both so this should work. Again, it is untested so let me know...
select: function(start){
// you may have to parse the date first aka. var start = Date.parse(start);
$("#calendar").fullCalendar('changeView', 'agendaWeek')
.fullCalendar('gotoDate', start);
}
As of version 2.3.1, fullCalendar does not let you chain commands. In order to achieve what you want is to call it twice.
dayClick: function(date){
$("#calendar").fullCalendar('changeView', 'agendaWeek');
$("#calendar").fullCalendar('gotoDate', date);
}
or
dayClick: function(date){
var $calendar=$("#calendar");
$calendar.fullCalendar('changeView', 'agendaWeek');
$calendar.fullCalendar('gotoDate', date);
}

Resources