Skip to content

Commit 2400cab

Browse files
committed
Add configuration option to sync past events
1 parent 01b5388 commit 2400cab

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ google.calendar.name=Outlook
101101
# Accepted value: integer greater than 0.
102102
total.sync.in.days=7
103103

104+
# Total days to sync past events from current day, or 0 to not sync past events.
105+
#
106+
# Accepted value: integer greater than or equal to 0.
107+
total.sync.in.days.past=7
108+
104109
# Next sync in minutes, or 0 to disable next run.
105110
#
106111
# Accepted value: integer.

src/main/groovy/com/github/choonchernlim/calsync/core/ExchangeToGoogleService.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ExchangeToGoogleService {
3333
assert userConfig
3434

3535
DateTime dateTimeNow = dateTimeNowSupplier.get()
36-
DateTime startDateTime = dateTimeNow.withTimeAtStartOfDay()
36+
DateTime startDateTime = dateTimeNow.minusDays(userConfig.totalSyncDaysPast).withTimeAtStartOfDay()
3737
DateTime endDateTime = startDateTime.plusDays(userConfig.totalSyncDays).minusMillis(1)
3838

3939
exchangeService.init(userConfig)

src/main/groovy/com/github/choonchernlim/calsync/core/UserConfig.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class UserConfig {
1414
String googleClientSecretJsonFilePath
1515
String googleCalendarName
1616
Integer totalSyncDays
17+
Integer totalSyncDaysPast
1718
Integer nextSyncInMinutes
1819
Boolean includeCanceledEvents
1920
Boolean includeEventBody

src/main/groovy/com/github/choonchernlim/calsync/core/UserConfigReader.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class UserConfigReader {
1616
static final String GOOGLE_CLIENT_SECRET_JSON_KEY = 'google.client.secret.json.file.path'
1717
static final String GOOGLE_CALENDAR_NAME_KEY = 'google.calendar.name'
1818
static final String TOTAL_SYNC_IN_DAYS_KEY = 'total.sync.in.days'
19+
static final String TOTAL_SYNC_IN_DAYS_PAST_KEY = 'total.sync.in.days.past'
1920
static final String NEXT_SYNC_IN_MINUTES_KEY = 'next.sync.in.minutes'
2021
static final String INCLUDE_CANCELED_EVENTS_KEY = 'include.canceled.events'
2122
static final String INCLUDE_EVENT_BODY_KEY = 'include.event.body'
@@ -78,6 +79,12 @@ class UserConfigReader {
7879
errors.add("${TOTAL_SYNC_IN_DAYS_KEY}: Must be greater than 0.")
7980
}
8081

82+
Integer totalSyncDaysPast = validatePropInteger(props, errors, TOTAL_SYNC_IN_DAYS_PAST_KEY)
83+
84+
if (totalSyncDaysPast != null && totalSyncDaysPast < 0) {
85+
errors.add("${TOTAL_SYNC_IN_DAYS_PAST_KEY}: Must be greater than or equal to 0.")
86+
}
87+
8188
Integer nextSyncInMinutes = validatePropInteger(props, errors, NEXT_SYNC_IN_MINUTES_KEY)
8289

8390
Boolean includeCanceledEvents = validatePropBoolean(props, errors, INCLUDE_CANCELED_EVENTS_KEY)
@@ -97,6 +104,7 @@ class UserConfigReader {
97104
googleClientSecretJsonFilePath: googleClientSecretJsonFilePath,
98105
googleCalendarName: googleCalendarName,
99106
totalSyncDays: totalSyncDays,
107+
totalSyncDaysPast: totalSyncDaysPast,
100108
nextSyncInMinutes: nextSyncInMinutes,
101109
includeCanceledEvents: includeCanceledEvents,
102110
includeEventBody: includeEventBody

src/main/resources/calsync-sample.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ google.calendar.name=Outlook
4444
# Accepted value: integer greater than 0.
4545
total.sync.in.days=7
4646

47+
# Total days to sync past events from current day, or 0 to not sync past events.
48+
#
49+
# Accepted value: integer greater than or equal to 0.
50+
total.sync.in.days.past=7
51+
4752
# Next sync in minutes, or 0 to disable next run.
4853
#
4954
# Accepted value: integer.

0 commit comments

Comments
 (0)