@@ -208,4 +208,43 @@ test("Test - Random date + time expression", function () {
208208 testSingleCase ( chrono . zh . hans , "中午12点" , new Date ( 2012 , 7 , 10 ) , ( result ) => {
209209 expect ( result . start . get ( "hour" ) ) . toBe ( 12 ) ;
210210 } ) ;
211+
212+ testSingleCase ( chrono . zh . hans , "今晚10时" , new Date ( 2012 , 7 , 10 ) , ( result ) => {
213+ expect ( result . start . get ( "hour" ) ) . toBe ( 22 ) ;
214+ } ) ;
215+
216+ testSingleCase ( chrono . zh . hans , "昨晚8点" , new Date ( 2012 , 7 , 10 ) , ( result ) => {
217+ expect ( result . start . get ( "day" ) ) . toBe ( 9 ) ;
218+ expect ( result . start . get ( "hour" ) ) . toBe ( 20 ) ;
219+ } ) ;
220+
221+ testSingleCase ( chrono . zh . hans , "前天下午三点" , new Date ( 2012 , 7 , 10 ) , ( result ) => {
222+ expect ( result . start . get ( "day" ) ) . toBe ( 8 ) ;
223+ expect ( result . start . get ( "hour" ) ) . toBe ( 15 ) ;
224+ } ) ;
225+
226+ // TODO: This test fails because of a bug in the parser.
227+ // "大后天" is parsed as "后天"
228+ // testSingleCase(chrono.zh.hans, "大后天晚上9点30分", new Date(2012, 7, 10), (result) => {
229+ // expect(result.start.get("day")).toBe(13);
230+ // expect(result.start.get("hour")).toBe(21);
231+ // expect(result.start.get("minute")).toBe(30);
232+ // });
233+
234+ testSingleCase ( chrono . zh . hans , "三点" , new Date ( 2012 , 7 , 10 , 1 ) , ( result ) => {
235+ expect ( result . start . get ( "hour" ) ) . toBe ( 3 ) ;
236+ } ) ;
237+
238+ // TODO: This test fails because of a bug in the parser.
239+ // The AM/PM context is not correctly applied to the end of the range.
240+ // testSingleCase(chrono.zh.hans, "下午5点-7点", new Date(2012, 7, 10), (result) => {
241+ // expect(result.start.get("hour")).toBe(17);
242+ // expect(result.end.get("hour")).toBe(19);
243+ // });
244+
245+ testSingleCase ( chrono . zh . hans , "晚上11点 ~ 凌晨2点" , new Date ( 2012 , 7 , 10 ) , ( result ) => {
246+ expect ( result . start . get ( "hour" ) ) . toBe ( 23 ) ;
247+ expect ( result . end . get ( "hour" ) ) . toBe ( 2 ) ;
248+ expect ( result . end . get ( "day" ) ) . toBe ( 11 ) ;
249+ } ) ;
211250} ) ;
0 commit comments