Skip to content

Commit

Permalink
fixed calendar event creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0Michine committed Feb 14, 2017
1 parent 783d49e commit bbaa968
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
40 changes: 23 additions & 17 deletions src/app.common/models/CalendarEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@ import "moment-timezone";
import { TimeSpanInfo } from "./TimeSpanInfo";

export class CalendarEvent {
static toCalendarEvent(timeSpan: TimeSpanInfo) {
const startTime = moment().hours(timeSpan.startHour).minutes(timeSpan.startMinute);
const endTime = moment().hours(timeSpan.endHour).minutes(timeSpan.endMinute);
const location = moment().tz();
static toCalendarEvent(timeSpan: TimeSpanInfo, location: string) {
const startTime = moment().hours(timeSpan.startHour).minutes(timeSpan.startMinute).seconds(0);
const endTime = moment().hours(timeSpan.endHour).minutes(timeSpan.endMinute).seconds(0);
const mail = "me@gmail.com";
var icsMSG =
`BEGIN:VCALENDAR` +
console.log(timeSpan, startTime.toISOString(), endTime.toISOString(), location);
const formatString = "YYYYMMDDTHHmmss[Z]";
const icsMSG =
`BEGIN:VCALENDAR\n` +
`VERSION:2.0\n` +
`PRODID:-//Worldtime//NONSGML v1.0//EN` +
`BEGIN:VEVENT` +
`UID:${mail}` +
`DTSTAMP:${moment().format()}` +
`ATTENDEE;CN=My Self ;RSVP=TRUE:MAILTO:${mail}` +
`ORGANIZER;CN=Me:MAILTO::${mail}` +
`DTSTART:${startTime.format()}` +
`DTEND:${endTime.format()}` +
`LOCATION:${location}` +
`SUMMARY:Our Meeting Office` +
`END:VEVENT` +
`PRODID:-//Worldtime//NONSGML v1.0//EN\n` +
`BEGIN:VEVENT\n` +
`UID:${mail}\n` +
// `DTSTAMP:${moment().toISOString()}\n` +
`DTSTAMP:${moment().utc().format(formatString)}\n` +
// `ATTENDEE;CN=My Self ;RSVP=TRUE:MAILTO:${mail}\n` +
// `ORGANIZER;CN=Me:MAILTO::${mail}\n` +
// `DTSTART:${startTime.toISOString()}\n` +
`DTSTART:${startTime.utc().format(formatString)}\n` +
// `DTSTART:${"20170214T123000Z"}\n` +
// `DTEND:${endTime.toISOString()}\n` +
`DTEND:${endTime.utc().format(formatString)}\n` +
// `DTEND:${"20170214T153000Z"}\n` +
`LOCATION:${location}\n` +
`SUMMARY:Our Meeting Office\n` +
`END:VEVENT\n` +
`END:VCALENDAR`;

window.open(`data:text/calendar;charset=utf8,${encodeURI(icsMSG)}`);
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type LayoutProps = LayoutStateProps & LayoutDispatchProps;
)
export class Layout extends React.Component<LayoutProps, any> {
render(): React.ReactElement<any> {
const { displaySettings, selectedTimeSpan, changeSelectedTimeSpan } = this.props;
const { displaySettings, selectedTimeSpan, changeSelectedTimeSpan, timeLines } = this.props;
const valueMin = selectedTimeSpan.startHour * 2 + selectedTimeSpan.startMinute / 30;
const valueMax = selectedTimeSpan.endHour * 2 + selectedTimeSpan.endMinute / 30;
const startTime = moment().hours(selectedTimeSpan.startHour).minutes(selectedTimeSpan.startMinute);
Expand All @@ -51,7 +51,7 @@ export class Layout extends React.Component<LayoutProps, any> {
<div className={style.app}>
<TimeSelector selectedTimeSpan={selectedTimeSpan}/>
<div>
{this.props.timeLines.map(tl =>
{timeLines.map(tl =>
<TimeLine key={tl.name} timeLine={tl} offset={getOffset(tl)} hours={getHoursWithOffset(getOffset(tl))} displaySettings={displaySettings} />
)}
</div>
Expand All @@ -77,7 +77,7 @@ export class Layout extends React.Component<LayoutProps, any> {
<div className="pull-right">
<button
className={`btn btn-default btn-material ${ buttonDisabled ? "disabled" : ""}`}
onClick={() => CalendarEvent.toCalendarEvent(selectedTimeSpan)}
onClick={() => CalendarEvent.toCalendarEvent(selectedTimeSpan, timeLines[0].timeZoneId)}
>Export ot .ics</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Worldtime",
"description": "All time zones in one click",
"version": "0.1.282",
"version": "0.1.284",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"options_page": "options.html",
"browser_action": {
Expand Down

0 comments on commit bbaa968

Please sign in to comment.