Create a FocusTime in GCalendar - calendar

how I can create a focus time in GCalendar per script. I have created this scipt but I get a error back. Does anyone use why I my understanding is correct the syntax is OK:
function myFunction() {
//Is is working
var event1 = CalendarApp.getDefaultCalendar().createEvent('MyTimeSlot', new Date('Juni 01, 2022 20:00:00 UTC'), new Date('Juni 01, 2022 21:00:00 UTC'));
// Error: ReferenceError: CalendarEvent is not defined
var event2 = CalendarApp.getDefaultCalendar(">>>MyTimeSlot with FOCUS TIME<<<", new Date('Juni 01, 2022 20:00:00 UTC'), new Date('Juni 01, 2022 21:00:00 UTC'), {type: CalendarEvent.EventType.FOCUS_TIME});
event1.setColor(CalendarApp.EventColor.PALE_BLUE);
event2.setColor(CalendarApp.EventColor.PALE_RED);
}
Greetings

The error on event2 is because you are creating a Focus Time event.
Update from comment
Do I understand correctly? It does not work?
Yes, the eventType parameter, as mentioned on the Events documentation is a read-only parameter.
There is already a feature request reported on Google's Issue Tracker for this, you can go there and star the issue to get updates on it:
Create programmatically Focus Time via the API CalendarApp coding in Google Script

Related

Dynamic form and date format in angularjs and node js

I hope you can help me I have some doubts about nodejs and angularjs, I'm just starting with this,
I am doing a project in nodejs with angularjs and I found this example of a project
Http://www.aorank.com/tutorial/angular_CRUD_demo/
my question
How can I do that to open another form within a same page as it does in the demo of the link? I hope you can explain me and my question is now about the format of the time, I am trying to get the date and now of this moment and for that use the following
Var datetime = require ('node-datetime');
Var date = Date.now ();
Var datenow = new Date (date);
Var date = datenow.toString ("dd-mm-yyyy HH: mm"). Replace (/ T /, '') .replace (/\..+/, '');
And the consula shows this as a result
Thu May 18 2017 12:17:59 GMT-0400 (CLT)
But I wish it was this way
2017-05-18 12:17:59
And the other doubt how I can make more dynamic and open a form inside another as in the demo link I leave, I hope you can help me and thank you for your time

DST issue with Codename one Calendar code

Creating the object for Calendar and get the time and hour and minute from it.
It gives one hour less in iPad devices for Easter Time Zone (-5:00).
is this existing, does we need to consider any code changes on creating the Calendar Object.
Calendar now = Calendar.getInstance();
Dialog.show("Time value -- 1", now.getTime().toString(),"ok",null);
now.set(Calendar.YEAR, now.get(Calendar.YEAR));
now.set(Calendar.MONTH, now.get(Calendar.MONTH));
now.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH));
now.set(Calendar.HOUR_OF_DAY, now.get(Calendar.HOUR_OF_DAY));
now.set(Calendar.MINUTE, now.get(Calendar.MINUTE));
now.set(Calendar.DAY_OF_WEEK, now.get(Calendar.DAY_OF_WEEK));
Dialog.show("Time value -- 2", now.getTime().toString(),"ok",null);
Dialog.show("Time value -- 3", " "+now.getTimeZone(),"OK",null);
java.util.TimeZone timeZone = (java.util.TimeZone)now.getTimeZone();
Dialog.show("timeZone.useDaylightTime() -- ", timeZone.useDaylightTime()+" " ,"ok",null);
From the above code in iPad version 10.2 and for Time Zone New York, U.S.A we are getting useDaylightTime as false. whereas in simulator its value is true.
is there any way to handle DST issue on iPads in codename one.
due to calendar code, we are getting 1 hour less from actual time.
Thanks in advance.
There was a bug in the iOS VM that is now fixed. The fix should be available on the build server soon (within the next day or so). That will fix this issue.

Angular JS - YouTube timestamp to UNIX

I'm trying to create an angular filter that converts my UNIX timestamp that I get from a datetimepicker to the YouTube formatted date and vice versa. I've searched everywhere but all I could find is a PHP function... Can someone provide assistance with this?
UNIX: 1440072453
YouTube: 2015-01-08T11:29:40.000Z
Example :
var d = new Date(Date.parse("2012-01-11T20:49:59.415Z"));
d.toString(); // => Wed Jan 11 2012 15:49:59 GMT-0500 (EST)
d.getTime(); // => 1326314999415
From Parsing a Youtube API Date in Javascript

Angular UI datepicker giving me a UTC converted string. How to parse it back to local time accounting for the time difference?

I am currently running into issues with datepicker automatically converting my time to UTC. Is there anything I can pass into datepicker for it to not give me back a UTC converted string? For example the user picks March 19 on the calendar and the returned string would be something like this
'2014-03-19T04:00:00.000Z'
What I want is ->
'2014-03-19T00:00:00-04:00'
What I am trying now (sort of hacking around it) is trying to use moment js to convert it back to my desired (expected) format, but I am having trouble doing so without hardcoding a subtraction in there. I want to be able to convert it from UTC back to local time.
Does anyone know of a solution to this using moment js or angular?
I ran into the same problem and used a filter that adjusts the date and time using the local data to get around it:
filter('adjustDatepicker', ['$filter', function($filter){
var dateFilter = $filter('date');
return function(dateToFix){
var localDate, localTime, localOffset, adjustedDate;
localDate = new Date(dateToFix);
localTime = localDate.getTime();
localOffset = localDate.getTimezoneOffset() * 60000;
adjustedDate = new Date(localTime + localOffset);
return dateFilter(adjustedDate, 'MM/dd/yyyy');
};
}])
Use it like this in your template file:
{{details.datetomodify | adjustDatepicker}}
I think new Date('2014-03-19T04:00:00.000Z').toString() will give you the local version of the UTC time.

Execute formatted time in a slice with html/template

I'm making this simple webserver that can host my blog, but whatever I do; I can not execute a proper formatted time into my html/template.
Here's what I do:
I've created this struct:
type Blogpost struct {
Title string
Content string
Date time.Time
}
Next up I've created this little func that retrieves the blogposts with corresponding title/dates from the Appengine Datastore and return that as a slice:
func GetBlogs(r *http.Request, max int) []Blogpost {
c := appengine.NewContext(r)
q := datastore.NewQuery("Blogpost").Order("-Date").Limit(max)
bp := make([]Blogpost, 0, max)
q.GetAll(c, &bp)
return bp
}
Finally, in the blogHandler I create a slice based on the retrieved data from the Appengine Datastore using:
blogs := GetBlogs(r, 10)
Now when I Execute my template called blog like this, the dates of the blogs are being parsed as default dates:
blog.Execute(w, blogs) // gives dates like: 2013-09-03 16:06:48 +0000 UTC
So, me, being the Golang n00b that I am, would say that a function like the following would give me the result I want
blogs[0].Date = blogs[0].Date.Format("02-01-2006 15:04:05") // Would return like 03-09-2013 16:06:48, at least when you print the formatted date that is.
However that results in a type conflict ofcourse, which I tried to solve using:
blogs[0].Date, _ = time.Parse("02-01-2006 15:04:05", blogs[0].Date.Format("02-01-2006 15:04:05")) // returns once again: 2013-09-03 16:06:48 +0000 UTC
It is probably some n00b thing I oversaw once again, but I just can't see how I can't override a time.Time Type in a slice or at least print it in the format that I want.
While I looking for a similar functionality to simply format and render a time.Time type in a html/template, I fortuitously discovered that go's template parser allows methods to be called under certain restrictions when rendering a time.Time type.
For example;
type Post struct {
Id int
Title string
CreatedOn time.Time
}
// post is a &Post. in my case, I fetched that from a postgresql
// table which has a datetime column for that field and
// value in db is 2015-04-04 20:51:48
template.Execute(w, post)
and it's possible to use that time in a template like below:
<span>{{ .CreatedOn }}</span>
<!-- Outputs: 2015-04-04 20:51:48 +0000 +0000 -->
<span>{{ .CreatedOn.Format "2006 Jan 02" }}</span>
<!-- Outputs: 2015 Apr 04 -->
<span>{{ .CreatedOn.Format "Jan 02, 2006" }}</span>
<!-- Outputs: Apr 04, 2015 -->
<span>{{.CreatedOn.Format "Jan 02, 2006 15:04:05 UTC" }}</span>
<!-- Outputs: Apr 04, 2015 20:51:48 UTC -->
As a note; my go version is go1.4.2 darwin/amd64
Hope it helps others.
Your Date field has type time.Time. If you format it as a string, and parse it back, you'll once again get a time.Time value, which will still print the default way when the template execution calls its String method, so it's not really solving your problem.
The way to solve it is by providing the template with the formatted time string itself instead of a time value, and you can do that in multiple ways. For example:
Add a method to your blog post type named FormattedDate or similar, which returns a string properly formatted in the style of your preference. That's the easiest, and probably the nicest way if you don't have a fancy use case.
Add a string field to your blog type named FormattedDate or similar; that's very similar to the above option, but you have to be careful to set and update the field whenever necessary, so I'd prefer the method option instead.
If you'd like to format time values in multiple ways within the template, you might also opt to define a template formatter function, so that you might do something like {{post.Date | fdate "02-01-2006 15:04:05"}}. See the documentation on Template.Funcs, the FuncMap type, and this example for details on how to do that.
Update: Sample code for the first option: http://play.golang.org/p/3QYdrDQ1YO
If you output a time.Time in a template it will be converted to a string. This default conversion is what you see. If you need a different format you have two possibilites:
Add a `FormatedDate string field to your Blogpost and populate it from Date via Date.Format(whatever)
Write and register a formatting filter` in your template (see http://golang.org/pkg/html/template/#Template.Funcs) and use this.

Resources