vb6parse 1.0.1

vb6parse is a library for parsing and analyzing VB6 code, from projects, to controls, to modules, and forms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
//! VB6 `TimeValue` Function
//!
//! The `TimeValue` function returns a Variant (Date) containing the time value represented by a string.
//!
//! ## Syntax
//! ```vb6
//! TimeValue(time)
//! ```
//!
//! ## Parameters
//! - `time`: Required. String expression representing a time (e.g., "14:30:00", "2:30 PM"). Can also be a Variant containing a string or a numeric value representing a time.
//!
//! ## Returns
//! Returns a `Variant` of subtype `Date` containing the time value. The date portion is set to zero (December 30, 1899).
//!
//! ## Remarks
//! The `TimeValue` function parses a string and returns the corresponding time value:
//!
//! - **String input**: Accepts time strings in various formats (e.g., "14:30", "2:30 PM", "23:59:59")
//! - **Date portion**: Always returns zero date (12/30/1899)
//! - **Locale aware**: Accepts time formats based on system locale
//! - **Numeric input**: Accepts numeric values representing fractional days (e.g., 0.5 = 12:00 PM)
//! - **Null handling**: Returns Null if input is Null
//! - **Error handling**: Error 13 (Type mismatch) if string cannot be parsed as a time
//! - **No milliseconds**: Only parses up to seconds
//! - **Companion to `DateValue`**: Use `DateValue` for date-only parsing
//! - **Type returned**: Returns Variant (Date), not a string
//!
//! ### Accepted Time Formats
//! - 24-hour: "14:30", "23:59:59"
//! - 12-hour: "2:30 PM", "11:59:59 PM"
//! - With/without seconds: "8:00", "8:00:00"
//! - With/without AM/PM: "7:15", "7:15 AM"
//! - Numeric: 0.75 (6:00 PM)
//!
//! ### Invalid Inputs
//! - "25:00" (invalid hour)
//! - "13:60" (invalid minute)
//! - "not a time" (not parseable)
//!
//! ## Typical Uses
//! 1. **Parse User Input**: Convert time strings to time values
//! 2. **Time Comparison**: Compare parsed times to other time values
//! 3. **Scheduling**: Store and use times from configuration or user entry
//! 4. **Time Calculations**: Perform arithmetic with parsed times
//! 5. **Validation**: Check if input is a valid time
//! 6. **Database Import**: Parse time strings from data sources
//! 7. **Time Filtering**: Filter records by parsed time
//! 8. **Time Formatting**: Convert string to time for display or calculation
//!
//! ## Basic Examples
//!
//! ### Example 1: Parse Time String
//! ```vb6
//! Sub ParseTime()
//!     Dim t As Date
//!     t = TimeValue("14:30:00")
//!     MsgBox "Parsed time: " & Format$(t, "hh:mm AM/PM")
//! End Sub
//! ```
//!
//! ### Example 2: Parse 12-hour Time
//! ```vb6
//! Function ParseNoon() As Date
//!     ParseNoon = TimeValue("12:00 PM")
//! End Function
//! ```
//!
//! ### Example 3: Validate Time Input
//! ```vb6
//! Function IsValidTime(inputStr As String) As Boolean
//!     On Error Resume Next
//!     Dim t As Date
//!     t = TimeValue(inputStr)
//!     IsValidTime = (Err.Number = 0)
//!     On Error GoTo 0
//! End Function
//! ```
//!
//! ### Example 4: Compare Parsed Time
//! ```vb6
//! Function IsAfterNoon(timeStr As String) As Boolean
//!     IsAfterNoon = (TimeValue(timeStr) > TimeValue("12:00 PM"))
//! End Function
//! ```
//!
//! ## Common Patterns
//!
//! ### Pattern 1: Parse and Add Minutes
//! ```vb6
//! Function AddMinutes(timeStr As String, minutes As Integer) As Date
//!     AddMinutes = TimeValue(timeStr) + TimeSerial(0, minutes, 0)
//! End Function
//! ```
//!
//! ### Pattern 2: Parse and Compare to Now
//! ```vb6
//! Function IsPast(timeStr As String) As Boolean
//!     IsPast = (TimeValue(timeStr) < Time)
//! End Function
//! ```
//!
//! ### Pattern 3: Parse and Format
//! ```vb6
//! Function FormatParsedTime(timeStr As String) As String
//!     FormatParsedTime = Format$(TimeValue(timeStr), "hh:mm:ss")
//! End Function
//! ```
//!
//! ### Pattern 4: Parse with Error Handling
//! ```vb6
//! Function TryParseTime(timeStr As String, ByRef result As Date) As Boolean
//!     On Error Resume Next
//!     result = TimeValue(timeStr)
//!     TryParseTime = (Err.Number = 0)
//!     On Error GoTo 0
//! End Function
//! ```
//!
//! ### Pattern 5: Parse Numeric Time
//! ```vb6
//! Function ParseNumericTime(numericValue As Double) As Date
//!     ParseNumericTime = TimeValue(numericValue)
//! End Function
//! ```
//!
//! ### Pattern 6: Parse and Set Property
//! ```vb6
//! Sub SetStartTime(obj As Object, timeStr As String)
//!     obj.StartTime = TimeValue(timeStr)
//! End Sub
//! ```
//!
//! ### Pattern 7: Parse Array of Times
//! ```vb6
//! Function ParseTimeArray(timeStrings() As String) As Variant
//!     Dim i As Integer
//!     Dim times() As Date
//!     ReDim times(LBound(timeStrings) To UBound(timeStrings))
//!     For i = LBound(timeStrings) To UBound(timeStrings)
//!         times(i) = TimeValue(timeStrings(i))
//!     Next i
//!     ParseTimeArray = times
//! End Function
//! ```
//!
//! ### Pattern 8: Filter Valid Times
//! ```vb6
//! Function FilterValidTimes(timeStrings() As String) As Collection
//!     Dim validTimes As New Collection
//!     Dim i As Integer
//!     For i = LBound(timeStrings) To UBound(timeStrings)
//!         If IsValidTime(timeStrings(i)) Then
//!             validTimes.Add TimeValue(timeStrings(i))
//!         End If
//!     Next i
//!     Set FilterValidTimes = validTimes
//! End Function
//! ```
//!
//! ### Pattern 9: Parse and Use in Schedule
//! ```vb6
//! Sub AddScheduleEntry(schedule As Collection, timeStr As String, description As String)
//!     Dim entry As New Collection
//!     entry.Add TimeValue(timeStr), "Time"
//!     entry.Add description, "Description"
//!     schedule.Add entry
//! End Sub
//! ```
//!
//! ### Pattern 10: Parse and Compare Range
//! ```vb6
//! Function IsWithinRange(timeStr As String, startStr As String, endStr As String) As Boolean
//!     Dim t As Date
//!     t = TimeValue(timeStr)
//!     IsWithinRange = (t >= TimeValue(startStr) And t <= TimeValue(endStr))
//! End Function
//! ```
//!
//! ## Advanced Usage
//!
//! ### Example 1: Time Parser Class
//! ```vb6
//! ' Class: TimeParser
//! ' Parses and validates time strings
//! Option Explicit
//!
//! Public Function Parse(timeStr As String) As Date
//!     Parse = TimeValue(timeStr)
//! End Function
//!
//! Public Function TryParse(timeStr As String, ByRef result As Date) As Boolean
//!     On Error Resume Next
//!     result = TimeValue(timeStr)
//!     TryParse = (Err.Number = 0)
//!     On Error GoTo 0
//! End Function
//!
//! Public Function IsValid(timeStr As String) As Boolean
//!     On Error Resume Next
//!     Dim t As Date
//!     t = TimeValue(timeStr)
//!     IsValid = (Err.Number = 0)
//!     On Error GoTo 0
//! End Function
//!
//! Public Function Format(timeStr As String, formatStr As String) As String
//!     Format = Format$(TimeValue(timeStr), formatStr)
//! End Function
//! ```
//!
//! ### Example 2: Schedule Importer Module
//! ```vb6
//! ' Module: ScheduleImporter
//! ' Imports and parses schedule times from data
//! Option Explicit
//!
//! Public Function ImportSchedule(times() As String, descriptions() As String) As Collection
//!     Dim schedule As New Collection
//!     Dim i As Integer
//!     For i = LBound(times) To UBound(times)
//!         Dim entry As New Collection
//!         entry.Add TimeValue(times(i)), "Time"
//!         entry.Add descriptions(i), "Description"
//!         schedule.Add entry
//!     Next i
//!     Set ImportSchedule = schedule
//! End Function
//!
//! Public Function GetEarliestTime(times() As String) As Date
//!     Dim minTime As Date
//!     Dim i As Integer
//!     minTime = TimeValue(times(LBound(times)))
//!     For i = LBound(times) + 1 To UBound(times)
//!         If TimeValue(times(i)) < minTime Then minTime = TimeValue(times(i))
//!     Next i
//!     GetEarliestTime = minTime
//! End Function
//!
//! Public Function GetLatestTime(times() As String) As Date
//!     Dim maxTime As Date
//!     Dim i As Integer
//!     maxTime = TimeValue(times(LBound(times)))
//!     For i = LBound(times) + 1 To UBound(times)
//!         If TimeValue(times(i)) > maxTime Then maxTime = TimeValue(times(i))
//!     Next i
//!     GetLatestTime = maxTime
//! End Function
//! ```
//!
//! ### Example 3: Time Validator Class
//! ```vb6
//! ' Class: TimeValidator
//! ' Validates and normalizes time strings
//! Option Explicit
//!
//! Public Function IsValid(timeStr As String) As Boolean
//!     On Error Resume Next
//!     Dim t As Date
//!     t = TimeValue(timeStr)
//!     IsValid = (Err.Number = 0)
//!     On Error GoTo 0
//! End Function
//!
//! Public Function Normalize(timeStr As String) As String
//!     On Error Resume Next
//!     Dim t As Date
//!     t = TimeValue(timeStr)
//!     If Err.Number = 0 Then
//!         Normalize = Format$(t, "hh:mm:ss")
//!     Else
//!         Normalize = ""
//!     End If
//!     On Error GoTo 0
//! End Function
//! ```
//!
//! ### Example 4: Time Range Analyzer Module
//! ```vb6
//! ' Module: TimeRangeAnalyzer
//! ' Analyzes and compares time ranges
//! Option Explicit
//!
//! Public Function GetTimeRange(times() As String) As String
//!     Dim minTime As Date, maxTime As Date
//!     Dim i As Integer
//!     minTime = TimeValue(times(LBound(times)))
//!     maxTime = minTime
//!     For i = LBound(times) + 1 To UBound(times)
//!         If TimeValue(times(i)) < minTime Then minTime = TimeValue(times(i))
//!         If TimeValue(times(i)) > maxTime Then maxTime = TimeValue(times(i))
//!     Next i
//!     GetTimeRange = Format$(minTime, "hh:mm") & " - " & Format$(maxTime, "hh:mm")
//! End Function
//!
//! Public Function IsWithinRange(timeStr As String, startStr As String, endStr As String) As Boolean
//!     Dim t As Date
//!     t = TimeValue(timeStr)
//!     IsWithinRange = (t >= TimeValue(startStr) And t <= TimeValue(endStr))
//! End Function
//! ```
//!
//! ## Error Handling
//! The `TimeValue` function can raise the following errors:
//!
//! - **Error 13 (Type mismatch)**: If the string cannot be parsed as a time
//! - **Returns Null**: If the input is Null (not an error)
//!
//! ## Performance Notes
//! - Fast operation - simple parsing
//! - Constant time O(1) complexity for valid strings
//! - Locale-dependent parsing speed
//! - Safe to call repeatedly
//!
//! ## Best Practices
//! 1. **Validate input** before calling if user-provided
//! 2. **Handle Null** explicitly when working with nullable fields
//! 3. **Use Format$** for display after parsing
//! 4. **Test with different locales** for internationalization
//! 5. **Use `TryParse` pattern** for robust error handling
//! 6. **Document expected formats** for maintainability
//! 7. **Store as Date type** for calculations
//! 8. **Use with `TimeSerial`** for arithmetic
//! 9. **Test edge cases** (midnight, noon, invalid times)
//! 10. **Combine with `DateValue`** for full date/time parsing
//!
//! ## Comparison Table
//!
//! | Function | Purpose | Input | Returns |
//! |----------|---------|-------|---------|
//! | `TimeValue` | Parse time from string | time string | Date (time only) |
//! | `DateValue` | Parse date from string | date string | Date (date only) |
//! | `TimeSerial` | Create time from components | hour, minute, second | Date (time only) |
//! | `DateSerial` | Create date from components | year, month, day | Date (date only) |
//! | `CDate` | Convert to date | expression | Date |
//!
//! ## Platform Notes
//! - Available in VB6, VBA, and `VBScript`
//! - Consistent behavior across platforms
//! - Locale-aware parsing
//! - Date portion always zero (12/30/1899)
//! - Compatible with all date/time functions
//!
//! ## Limitations
//! - Only parses up to seconds (no milliseconds)
//! - Locale-dependent parsing (may fail on some formats)
//! - Cannot parse date and time together (use `CDate` for full datetime)
//! - No timezone support
//! - No daylight saving time handling
//! - Returns only time portion (date is zero)
//! - Error on invalid input (not Null)

#[cfg(test)]
mod tests {
    use crate::*;

    #[test]
    fn timevalue_basic() {
        let source = r#"
Sub Test()
    t = TimeValue("14:30:00")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_12_hour() {
        let source = r#"
Sub Test()
    noon = TimeValue("12:00 PM")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_variable_assignment() {
        let source = r#"
Sub Test()
    Dim myTime As Date
    myTime = TimeValue("8:15")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_function_return() {
        let source = r"
Function ParseTime(s As String) As Date
    ParseTime = TimeValue(s)
End Function
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_add_minutes() {
        let source = r#"
Sub Test()
    newTime = TimeValue("10:00") + TimeSerial(0, 30, 0)
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_comparison() {
        let source = r#"
Sub Test()
    If TimeValue("15:00") > TimeValue("12:00") Then
        Afternoon
    End If
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_msgbox() {
        let source = r#"
Sub Test()
    MsgBox "Parsed: " & TimeValue("7:45 AM")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_debug_print() {
        let source = r#"
Sub Test()
    Debug.Print TimeValue("23:59:59")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_format() {
        let source = r#"
Sub Test()
    formatted = Format$(TimeValue("18:30"), "hh:mm AM/PM")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_if_statement() {
        let source = r#"
Sub Test()
    If TimeValue("6:00 PM") > TimeValue("12:00 PM") Then
        Evening
    End If
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_select_case() {
        let source = r#"
Sub Test()
    Select Case TimeValue("8:00")
        Case Is < TimeValue("12:00")
            Morning
        Case Else
            Afternoon
    End Select
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_property_assignment() {
        let source = r#"
Sub Test()
    obj.Time = TimeValue("13:45")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_with_statement() {
        let source = r#"
Sub Test()
    With schedule
        .Start = TimeValue("8:00")
        .End = TimeValue("17:00")
    End With
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_array_assignment() {
        let source = r"
Sub Test()
    times(i) = TimeValue(timeStrings(i))
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_print_statement() {
        let source = r#"
Sub Test()
    Print #1, TimeValue("10:15:30")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_elseif() {
        let source = r#"
Sub Test()
    If x = 1 Then
        y = 1
    ElseIf TimeValue("18:00") > TimeValue("12:00") Then
        y = 2
    End If
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_do_while() {
        let source = r#"
Sub Test()
    Do While TimeValue("15:00") > TimeValue("12:00")
        Process
    Loop
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_do_until() {
        let source = r#"
Sub Test()
    Do Until TimeValue("8:00") >= TimeValue("17:00")
        Wait
    Loop
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_while_wend() {
        let source = r#"
Sub Test()
    While TimeValue("9:00") < TimeValue("17:00")
        Work
    Wend
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_iif() {
        let source = r#"
Sub Test()
    greeting = IIf(TimeValue("8:00") < TimeValue("12:00"), "Morning", "Afternoon")
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_parentheses() {
        let source = r#"
Sub Test()
    result = (TimeValue("12:00"))
End Sub
"#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn timevalue_numeric_input() {
        let source = r"
Sub Test()
    t = TimeValue(0.5)
End Sub
";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");
        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/datetime/timevalue",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }
}