@@ -629,7 +629,7 @@ protected List<EventModel> GetFilteredEvents(CalendarSkillState state, string us
629629 showingCardTitle = null ;
630630
631631 // filter meetings with start time
632- var timeResult = RecognizeDateTime ( userInput , locale , false ) ;
632+ var timeResult = RecognizeDateTime ( userInput , locale , state . GetUserTimeZone ( ) , false ) ;
633633 if ( filteredMeetingList . Count <= 0 && timeResult != null )
634634 {
635635 foreach ( var result in timeResult )
@@ -767,33 +767,6 @@ protected async Task<string> GetUserPhotoUrlAsync(ITurnContext context, EventMod
767767 return string . Format ( AdaptiveCardHelper . DefaultAvatarIconPathFormat , displayName ) ;
768768 }
769769
770- protected bool IsRelativeTime ( string userInput , string resolverResult , string timex )
771- {
772- var userInputLower = userInput . ToLower ( ) ;
773- if ( userInputLower . Contains ( CalendarCommonStrings . Ago ) ||
774- userInputLower . Contains ( CalendarCommonStrings . Before ) ||
775- userInputLower . Contains ( CalendarCommonStrings . Later ) ||
776- userInputLower . Contains ( CalendarCommonStrings . Next ) )
777- {
778- return true ;
779- }
780-
781- if ( userInputLower . Contains ( CalendarCommonStrings . TodayLower ) ||
782- userInputLower . Contains ( CalendarCommonStrings . Now ) ||
783- userInputLower . Contains ( CalendarCommonStrings . YesterdayLower ) ||
784- userInputLower . Contains ( CalendarCommonStrings . TomorrowLower ) )
785- {
786- return true ;
787- }
788-
789- if ( timex == "PRESENT_REF" )
790- {
791- return true ;
792- }
793-
794- return false ;
795- }
796-
797770 protected async Task DigestCalendarLuisResult ( DialogContext dc , CalendarLuis luisResult , General generalLuisResult , bool isBeginDialog )
798771 {
799772 try
@@ -901,7 +874,7 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
901874
902875 if ( entity . Duration != null )
903876 {
904- var duration = GetDurationFromEntity ( entity , dc . Context . Activity . Locale ) ;
877+ var duration = GetDurationFromEntity ( entity , dc . Context . Activity . Locale , state . GetUserTimeZone ( ) ) ;
905878 if ( duration != - 1 )
906879 {
907880 state . MeetingInfor . CreateHasDetail = true ;
@@ -1047,12 +1020,12 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
10471020
10481021 if ( entity . MoveEarlierTimeSpan != null )
10491022 {
1050- state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveEarlierTimeSpan [ 0 ] , dc . Context . Activity . Locale , false ) ;
1023+ state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveEarlierTimeSpan [ 0 ] , dc . Context . Activity . Locale , false , state . GetUserTimeZone ( ) ) ;
10511024 }
10521025
10531026 if ( entity . MoveLaterTimeSpan != null )
10541027 {
1055- state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveLaterTimeSpan [ 0 ] , dc . Context . Activity . Locale , true ) ;
1028+ state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveLaterTimeSpan [ 0 ] , dc . Context . Activity . Locale , true , state . GetUserTimeZone ( ) ) ;
10561029 }
10571030
10581031 if ( entity . datetime != null )
@@ -1159,9 +1132,10 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
11591132 }
11601133 }
11611134
1162- protected List < DateTimeResolution > RecognizeDateTime ( string dateTimeString , string culture , bool convertToDate = true )
1135+ protected List < DateTimeResolution > RecognizeDateTime ( string dateTimeString , string culture , TimeZoneInfo userTimeZone , bool convertToDate = true )
11631136 {
1164- var results = DateTimeRecognizer . RecognizeDateTime ( DateTimeHelper . ConvertNumberToDateTimeString ( dateTimeString , convertToDate ) , culture , options : DateTimeOptions . CalendarMode ) ;
1137+ var userNow = TimeConverter . ConvertUtcToUserTime ( DateTime . UtcNow , userTimeZone ) ;
1138+ var results = DateTimeRecognizer . RecognizeDateTime ( DateTimeHelper . ConvertNumberToDateTimeString ( dateTimeString , convertToDate ) , culture , DateTimeOptions . CalendarMode , userNow ) ;
11651139
11661140 if ( results . Count > 0 )
11671141 {
@@ -1529,10 +1503,10 @@ private async Task<List<Card>> GetMeetingCardListAsync(CalendarSkillState state,
15291503 return eventItemList ;
15301504 }
15311505
1532- private int GetDurationFromEntity ( CalendarLuis . _Entities entity , string local )
1506+ private int GetDurationFromEntity ( CalendarLuis . _Entities entity , string local , TimeZoneInfo userTimeZone )
15331507 {
15341508 var culture = local ?? English ;
1535- var result = RecognizeDateTime ( entity . Duration [ 0 ] , culture ) ;
1509+ var result = RecognizeDateTime ( entity . Duration [ 0 ] , culture , userTimeZone ) ;
15361510 if ( result != null )
15371511 {
15381512 if ( result [ 0 ] . Value != null )
@@ -1544,10 +1518,10 @@ private int GetDurationFromEntity(CalendarLuis._Entities entity, string local)
15441518 return - 1 ;
15451519 }
15461520
1547- private int GetMoveTimeSpanFromEntity ( string timeSpan , string local , bool later )
1521+ private int GetMoveTimeSpanFromEntity ( string timeSpan , string local , bool later , TimeZoneInfo userTimeZone )
15481522 {
15491523 var culture = local ?? English ;
1550- var result = RecognizeDateTime ( timeSpan , culture ) ;
1524+ var result = RecognizeDateTime ( timeSpan , culture , userTimeZone ) ;
15511525 if ( result != null )
15521526 {
15531527 if ( result [ 0 ] . Value != null )
@@ -1585,7 +1559,7 @@ private List<DateTime> GetDateFromDateTimeString(string date, string local, Time
15851559 {
15861560 // if isTargetTimeRange is true, will only parse the time range
15871561 var culture = local ?? English ;
1588- var results = RecognizeDateTime ( date , culture , true ) ;
1562+ var results = RecognizeDateTime ( date , culture , userTimeZone , true ) ;
15891563 var dateTimeResults = new List < DateTime > ( ) ;
15901564 if ( results != null )
15911565 {
@@ -1603,8 +1577,7 @@ private List<DateTime> GetDateFromDateTimeString(string date, string local, Time
16031577
16041578 if ( dateTime != null )
16051579 {
1606- var isRelativeTime = IsRelativeTime ( date , result . Value , result . Timex ) ;
1607- dateTimeResults . Add ( isRelativeTime ? TimeZoneInfo . ConvertTime ( dateTime , TimeZoneInfo . Local , userTimeZone ) : dateTime ) ;
1580+ dateTimeResults . Add ( dateTime ) ;
16081581 }
16091582 }
16101583 else
@@ -1630,7 +1603,7 @@ private List<DateTime> GetTimeFromDateTimeString(string time, string local, Time
16301603 {
16311604 // if isTargetTimeRange is true, will only parse the time range
16321605 var culture = local ?? English ;
1633- var results = RecognizeDateTime ( time , culture , false ) ;
1606+ var results = RecognizeDateTime ( time , culture , userTimeZone , false ) ;
16341607 var dateTimeResults = new List < DateTime > ( ) ;
16351608 if ( results != null )
16361609 {
@@ -1648,8 +1621,7 @@ private List<DateTime> GetTimeFromDateTimeString(string time, string local, Time
16481621
16491622 if ( dateTime != null )
16501623 {
1651- var isRelativeTime = IsRelativeTime ( time , result . Value , result . Timex ) ;
1652- dateTimeResults . Add ( isRelativeTime ? TimeZoneInfo . ConvertTime ( dateTime , TimeZoneInfo . Local , userTimeZone ) : dateTime ) ;
1624+ dateTimeResults . Add ( dateTime ) ;
16531625 }
16541626 }
16551627 else
0 commit comments