@@ -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
@@ -900,7 +873,7 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
900873
901874 if ( entity . Duration != null )
902875 {
903- var duration = GetDurationFromEntity ( entity , dc . Context . Activity . Locale ) ;
876+ var duration = GetDurationFromEntity ( entity , dc . Context . Activity . Locale , state . GetUserTimeZone ( ) ) ;
904877 if ( duration != - 1 )
905878 {
906879 state . MeetingInfor . CreateHasDetail = true ;
@@ -1040,12 +1013,12 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
10401013
10411014 if ( entity . MoveEarlierTimeSpan != null )
10421015 {
1043- state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveEarlierTimeSpan [ 0 ] , dc . Context . Activity . Locale , false ) ;
1016+ state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveEarlierTimeSpan [ 0 ] , dc . Context . Activity . Locale , false , state . GetUserTimeZone ( ) ) ;
10441017 }
10451018
10461019 if ( entity . MoveLaterTimeSpan != null )
10471020 {
1048- state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveLaterTimeSpan [ 0 ] , dc . Context . Activity . Locale , true ) ;
1021+ state . UpdateMeetingInfor . MoveTimeSpan = GetMoveTimeSpanFromEntity ( entity . MoveLaterTimeSpan [ 0 ] , dc . Context . Activity . Locale , true , state . GetUserTimeZone ( ) ) ;
10491022 }
10501023
10511024 if ( entity . datetime != null )
@@ -1152,9 +1125,10 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
11521125 }
11531126 }
11541127
1155- protected List < DateTimeResolution > RecognizeDateTime ( string dateTimeString , string culture , bool convertToDate = true )
1128+ protected List < DateTimeResolution > RecognizeDateTime ( string dateTimeString , string culture , TimeZoneInfo userTimeZone , bool convertToDate = true )
11561129 {
1157- var results = DateTimeRecognizer . RecognizeDateTime ( DateTimeHelper . ConvertNumberToDateTimeString ( dateTimeString , convertToDate ) , culture , options : DateTimeOptions . CalendarMode ) ;
1130+ var userNow = TimeConverter . ConvertUtcToUserTime ( DateTime . UtcNow , userTimeZone ) ;
1131+ var results = DateTimeRecognizer . RecognizeDateTime ( DateTimeHelper . ConvertNumberToDateTimeString ( dateTimeString , convertToDate ) , culture , DateTimeOptions . CalendarMode , userNow ) ;
11581132
11591133 if ( results . Count > 0 )
11601134 {
@@ -1522,10 +1496,10 @@ private async Task<List<Card>> GetMeetingCardListAsync(CalendarSkillState state,
15221496 return eventItemList ;
15231497 }
15241498
1525- private int GetDurationFromEntity ( CalendarLuis . _Entities entity , string local )
1499+ private int GetDurationFromEntity ( CalendarLuis . _Entities entity , string local , TimeZoneInfo userTimeZone )
15261500 {
15271501 var culture = local ?? English ;
1528- var result = RecognizeDateTime ( entity . Duration [ 0 ] , culture ) ;
1502+ var result = RecognizeDateTime ( entity . Duration [ 0 ] , culture , userTimeZone ) ;
15291503 if ( result != null )
15301504 {
15311505 if ( result [ 0 ] . Value != null )
@@ -1537,10 +1511,10 @@ private int GetDurationFromEntity(CalendarLuis._Entities entity, string local)
15371511 return - 1 ;
15381512 }
15391513
1540- private int GetMoveTimeSpanFromEntity ( string timeSpan , string local , bool later )
1514+ private int GetMoveTimeSpanFromEntity ( string timeSpan , string local , bool later , TimeZoneInfo userTimeZone )
15411515 {
15421516 var culture = local ?? English ;
1543- var result = RecognizeDateTime ( timeSpan , culture ) ;
1517+ var result = RecognizeDateTime ( timeSpan , culture , userTimeZone ) ;
15441518 if ( result != null )
15451519 {
15461520 if ( result [ 0 ] . Value != null )
@@ -1577,7 +1551,7 @@ private string GetDateTimeStringFromInstanceData(string inputString, InstanceDat
15771551 private List < DateTime > GetDateFromDateTimeString ( string date , string local , TimeZoneInfo userTimeZone , bool isStart = true )
15781552 {
15791553 var culture = local ?? English ;
1580- var results = RecognizeDateTime ( date , culture , true ) ;
1554+ var results = RecognizeDateTime ( date , culture , userTimeZone , true ) ;
15811555 var dateTimeResults = new List < DateTime > ( ) ;
15821556 if ( results != null )
15831557 {
@@ -1595,8 +1569,7 @@ private List<DateTime> GetDateFromDateTimeString(string date, string local, Time
15951569
15961570 if ( dateTime != null )
15971571 {
1598- var isRelativeTime = IsRelativeTime ( date , result . Value , result . Timex ) ;
1599- dateTimeResults . Add ( isRelativeTime ? TimeZoneInfo . ConvertTime ( dateTime , TimeZoneInfo . Local , userTimeZone ) : dateTime ) ;
1572+ dateTimeResults . Add ( dateTime ) ;
16001573 }
16011574 }
16021575 else
@@ -1622,7 +1595,7 @@ private List<DateTime> GetTimeFromDateTimeString(string time, string local, Time
16221595 {
16231596 // if isStart is false, will only get the end time of a timerange
16241597 var culture = local ?? English ;
1625- var results = RecognizeDateTime ( time , culture , false ) ;
1598+ var results = RecognizeDateTime ( time , culture , userTimeZone , false ) ;
16261599 var dateTimeResults = new List < DateTime > ( ) ;
16271600 if ( results != null )
16281601 {
@@ -1640,8 +1613,7 @@ private List<DateTime> GetTimeFromDateTimeString(string time, string local, Time
16401613
16411614 if ( dateTime != null )
16421615 {
1643- var isRelativeTime = IsRelativeTime ( time , result . Value , result . Timex ) ;
1644- dateTimeResults . Add ( isRelativeTime ? TimeZoneInfo . ConvertTime ( dateTime , TimeZoneInfo . Local , userTimeZone ) : dateTime ) ;
1616+ dateTimeResults . Add ( dateTime ) ;
16451617 }
16461618 }
16471619 else
0 commit comments