-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9e80a0
commit 615e2d1
Showing
10 changed files
with
88 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,70 @@ | ||
import * as moment from "moment"; | ||
import "moment-timezone"; | ||
|
||
import { TimeSpanInfo } from "./TimeSpanInfo"; | ||
import { TimeSpanInfo, TimeZoneInfo } from "./"; | ||
|
||
export class CalendarEvent { | ||
static exportToICS(timeSpan: TimeSpanInfo, location: string) { | ||
function timeSpanToTime(timeSpan: TimeSpanInfo) { | ||
const startTime = moment().hours(timeSpan.startHour).minutes(timeSpan.startMinute).seconds(0); | ||
const endTime = moment().hours(timeSpan.endHour).minutes(timeSpan.endMinute).seconds(0); | ||
const mail = "[email protected]"; | ||
console.log(timeSpan, startTime.toISOString(), endTime.toISOString(), location); | ||
return {startTime, endTime}; | ||
} | ||
|
||
function getEventDescription(timeSpan: TimeSpanInfo, timelines: TimeZoneInfo[], newLine: string = "\n") { | ||
const {startTime, endTime} = timeSpanToTime(timeSpan); | ||
const footer = `${newLine}${newLine}${newLine}Scheduled with worldtime extension${newLine}`; | ||
return timelines.map((tl: TimeZoneInfo) => | ||
// `\n${tl.name}, ${tl.timeZoneId.replace("/", ", ").replace("_", " ")}\n` + | ||
`${newLine}${tl.name}${newLine}` + | ||
`${startTime.tz(tl.timeZoneId).format("h:mma\tddd, MMM D YYYY")}${newLine}` + | ||
`${endTime.tz(tl.timeZoneId).format("h:mma\tddd, MMM D YYYY")}` | ||
).concat(footer).join(`${newLine}`); | ||
} | ||
|
||
export class CalendarEvent { | ||
static exportToICS(timeSpan: TimeSpanInfo, location: string, timelines: TimeZoneInfo[]) { | ||
const {startTime, endTime} = timeSpanToTime(timeSpan); | ||
const description = getEventDescription(timeSpan, timelines, "\\n"); | ||
const formatString = "YYYYMMDDTHHmmss[Z]"; | ||
const mail = "[email protected]"; | ||
const icsMSG = | ||
`BEGIN:VCALENDAR\n` + | ||
`VERSION:2.0\n` + | ||
`PRODID:-//Worldtime//NONSGML v1.0//EN\n` + | ||
`BEGIN:VEVENT\n` + | ||
`UID:${mail}\n` + | ||
// `DTSTAMP:${moment().toISOString()}\n` + | ||
`DESCRIPTION:${description}\n` + | ||
`UID:worldtime\n` + | ||
`DTSTART:${startTime.utc().format(formatString)}\n` + | ||
`DTSTAMP:${moment().utc().format(formatString)}\n` + | ||
`DTEND:${endTime.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` + | ||
`SUMMARY:Let's Meet\n` + | ||
`END:VEVENT\n` + | ||
`END:VCALENDAR`; | ||
|
||
window.open(`data:text/calendar;charset=utf8,${encodeURI(icsMSG)}`); | ||
window.open(`data:text/calendar;charset=utf8,${encodeURI(icsMSG)}`); | ||
} | ||
|
||
static copyToClipboard(timeSpan: TimeSpanInfo, location: string) { | ||
static getGoogleCalendarLink(timeSpan: TimeSpanInfo, location: string, timelines: TimeZoneInfo[]) { | ||
const {startTime, endTime} = timeSpanToTime(timeSpan); | ||
const description = getEventDescription(timeSpan, timelines); | ||
const formatString = "YYYYMMDDTHHmmss[Z]"; | ||
const link = `http://www.google.com/calendar/event?action=TEMPLATE` + | ||
`&text=${"Let's Meet"}` + | ||
`&dates=${startTime.utc().format(formatString)}/${endTime.utc().format(formatString)}` + | ||
`&details=${description}` + | ||
`&location=${location}` + | ||
`&trp=true`; | ||
window.open(encodeURI(link)); | ||
} | ||
|
||
static copyToClipboard(timeSpan: TimeSpanInfo, location: string, timelines: TimeZoneInfo[]) { | ||
const {startTime, endTime} = timeSpanToTime(timeSpan); | ||
const sceduleData = getEventDescription(timeSpan, timelines); | ||
|
||
let copyFrom = document.createElement("textarea"); | ||
copyFrom.textContent = "copy content"; | ||
copyFrom.textContent = sceduleData; | ||
document.body.appendChild(copyFrom); | ||
copyFrom.focus(); | ||
document.execCommand('SelectAll'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ const initialState = { | |
createTimeZoneInfo("Asia/Yekaterinburg", "Yekaterinburg") | ||
], | ||
editTimeLineForm: { name: "", timeZoneId: "" } as TimeZoneInfo, | ||
displaySettings: { showDST: "hide", showTimeZoneId: false, showUTCOffset: true }, | ||
displaySettings: { showDST: "hide", showTimeZoneId: false, showUTCOffset: true, showControlPanel: true }, | ||
selectedTimeSpan: { startHour: 0, startMinute: 0, endHour: 24, endMinute: 0 } | ||
} as AppState; | ||
|
||
|
@@ -51,7 +51,7 @@ if (process.env.NODE_ENV === "development") { | |
} else { | ||
enchancer = compose( | ||
persistState("timeLines", { key: "[email protected]" }), | ||
persistState("displaySettings", { key: "[email protected].265" }) | ||
persistState("displaySettings", { key: "[email protected].288" }) | ||
) as any; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters