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
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
//! # `Time$` Function
//!
//! The `Time$` function in Visual Basic 6 returns a string representing the current system time.
//! The dollar sign (`$`) suffix indicates that this function always returns a `String` type,
//! never a `Variant`.
//!
//! ## Syntax
//!
//! ```vb6
//! Time$
//! ```
//!
//! ## Parameters
//!
//! None. `Time$` takes no parameters.
//!
//! ## Return Value
//!
//! Returns a `String` representing the current system time in the format "HH:MM:SS" (24-hour format).
//!
//! ## Behavior and Characteristics
//!
//! ### Time Format
//!
//! - Always returns 24-hour format (e.g., "14:30:45" for 2:30:45 PM)
//! - Format: "HH:MM:SS" where HH is 00-23, MM is 00-59, SS is 00-59
//! - Always includes leading zeros (e.g., "09:05:03")
//! - Does not include AM/PM indicator
//! - Does not include milliseconds or fractional seconds
//!
//! ### Type Differences: `Time$` vs `Time`
//!
//! - `Time$`: Always returns `String` type (never `Variant`)
//! - `Time`: Returns `Variant` containing a Date/Time value
//! - Use `Time$` when you need a string representation
//! - Use `Time` when you need to perform date/time arithmetic
//!
//! ### System Time
//!
//! - Reflects the current system clock time
//! - Updates each time the function is called
//! - Accuracy depends on system clock resolution
//! - No time zone information included
//!
//! ## Common Usage Patterns
//!
//! ### 1. Display Current Time
//!
//! ```vb6
//! Sub ShowTime()
//!     Debug.Print "Current time: " & Time$
//! End Sub
//! ```
//!
//! ### 2. Timestamp for Logging
//!
//! ```vb6
//! Sub LogMessage(message As String)
//!     Dim logEntry As String
//!     logEntry = Time$ & " - " & message
//!     Debug.Print logEntry
//! End Sub
//!
//! LogMessage "Application started"
//! ```
//!
//! ### 3. Time-Based File Naming
//!
//! ```vb6
//! Function GenerateTimeStampedFileName(baseName As String) As String
//!     Dim timeStamp As String
//!     timeStamp = Replace$(Time$, ":", "")
//!     GenerateTimeStampedFileName = baseName & "_" & timeStamp & ".log"
//! End Function
//!
//! ' Generates: "logfile_143045.log" at 2:30:45 PM
//! ```
//!
//! ### 4. Update Time Display
//!
//! ```vb6
//! Sub Timer1_Timer()
//!     ' Update label every second
//!     lblTime.Caption = Time$
//! End Sub
//! ```
//!
//! ### 5. Record Processing Time
//!
//! ```vb6
//! Sub ProcessData()
//!     Dim startTime As String
//!     startTime = Time$
//!     
//!     ' ... processing code ...
//!     
//!     Debug.Print "Started at: " & startTime
//!     Debug.Print "Completed at: " & Time$
//! End Sub
//! ```
//!
//! ### 6. Time-Based Greetings
//!
//! ```vb6
//! Function GetGreeting() As String
//!     Dim currentHour As Integer
//!     currentHour = Hour(Now)
//!     
//!     If currentHour < 12 Then
//!         GetGreeting = "Good morning! Time: " & Time$
//!     ElseIf currentHour < 18 Then
//!         GetGreeting = "Good afternoon! Time: " & Time$
//!     Else
//!         GetGreeting = "Good evening! Time: " & Time$
//!     End If
//! End Function
//! ```
//!
//! ### 7. Audit Trail Entries
//!
//! ```vb6
//! Sub RecordAudit(action As String, userName As String)
//!     Dim auditEntry As String
//!     auditEntry = Date$ & " " & Time$ & " - " & userName & " - " & action
//!     Print #1, auditEntry
//! End Sub
//! ```
//!
//! ### 8. Periodic Task Checking
//!
//! ```vb6
//! Sub CheckScheduledTask()
//!     Dim currentTimeStr As String
//!     currentTimeStr = Time$
//!     
//!     If currentTimeStr = "09:00:00" Then
//!         ' Execute morning task
//!         RunMorningReport
//!     End If
//! End Sub
//! ```
//!
//! ### 9. Status Bar Updates
//!
//! ```vb6
//! Sub UpdateStatusBar()
//!     StatusBar1.Panels(1).Text = "Current Time: " & Time$
//! End Sub
//! ```
//!
//! ### 10. Debug Output with Timestamps
//!
//! ```vb6
//! Sub DebugLog(category As String, message As String)
//!     Debug.Print "[" & Time$ & "] " & category & ": " & message
//! End Sub
//!
//! DebugLog "INFO", "Processing started"
//! ```
//!
//! ## Related Functions
//!
//! - `Time` - Returns a `Variant` containing the current system time (can be used in calculations)
//! - `Date$` - Returns a string representing the current system date
//! - `Now` - Returns the current system date and time as a `Date` value
//! - `Timer` - Returns the number of seconds elapsed since midnight
//! - `Hour()` - Extracts the hour component from a time value
//! - `Minute()` - Extracts the minute component from a time value
//! - `Second()` - Extracts the second component from a time value
//! - `Format$()` - Formats time values with custom formatting
//! - `TimeSerial()` - Creates a time value from hour, minute, and second
//! - `TimeValue()` - Converts a string to a time value
//!
//! ## Best Practices
//!
//! ### When to Use `Time$` vs `Time` vs `Now`
//!
//! ```vb6
//! ' Use Time$ for string display/logging
//! Debug.Print "Current time: " & Time$  ' "14:30:45"
//!
//! ' Use Time for time arithmetic
//! Dim currentTime As Date
//! currentTime = Time
//! Dim laterTime As Date
//! laterTime = currentTime + TimeSerial(1, 0, 0)  ' Add 1 hour
//!
//! ' Use Now for complete timestamp
//! Dim timestamp As Date
//! timestamp = Now  ' Includes both date and time
//! ```
//!
//! ### Combine with `Date$` for Full Timestamp
//!
//! ```vb6
//! Function GetFullTimestamp() As String
//!     GetFullTimestamp = Date$ & " " & Time$
//! End Function
//!
//! Debug.Print GetFullTimestamp()  ' "12/02/2025 14:30:45"
//! ```
//!
//! ### Use `Format$` for Custom Time Formatting
//!
//! ```vb6
//! ' Time$ always returns 24-hour format
//! Debug.Print Time$  ' "14:30:45"
//!
//! ' Use Format$ for 12-hour format or other formats
//! Debug.Print Format$(Now, "hh:mm:ss AM/PM")  ' "02:30:45 PM"
//! Debug.Print Format$(Now, "Long Time")       ' "2:30:45 PM"
//! ```
//!
//! ### Replace Colons for File Names
//!
//! ```vb6
//! Function SafeTimeStamp() As String
//!     ' Colons are invalid in filenames on Windows
//!     SafeTimeStamp = Replace$(Time$, ":", "")
//! End Function
//!
//! Dim fileName As String
//! fileName = "backup_" & SafeTimeStamp() & ".dat"  ' "backup_143045.dat"
//! ```
//!
//! ## Performance Considerations
//!
//! - `Time$` is a system call and relatively fast
//! - Calling repeatedly in tight loops may impact performance
//! - Cache the value if you need it multiple times in the same operation
//!
//! ```vb6
//! ' Less efficient: multiple calls
//! For i = 1 To 1000
//!     Debug.Print Time$ & " - Item " & i
//! Next i
//!
//! ' More efficient: cache the time
//! Dim currentTime As String
//! currentTime = Time$
//! For i = 1 To 1000
//!     Debug.Print currentTime & " - Item " & i
//! Next i
//! ```
//!
//! ## Common Pitfalls
//!
//! ### 1. 24-Hour Format Only
//!
//! ```vb6
//! ' Time$ always uses 24-hour format
//! Debug.Print Time$  ' "14:30:45" (not "2:30:45 PM")
//!
//! ' For 12-hour format, use Format$
//! Debug.Print Format$(Now, "hh:mm:ss AM/PM")  ' "02:30:45 PM"
//! ```
//!
//! ### 2. String Comparison Issues
//!
//! ```vb6
//! ' Comparing time strings can be tricky
//! If Time$ = "9:00:00" Then  ' Will NEVER match!
//!     ' Time$ returns "09:00:00" with leading zero
//! End If
//!
//! ' Correct: include leading zero
//! If Time$ = "09:00:00" Then
//!     ' This works
//! End If
//!
//! ' Better: use Time value for comparisons
//! If Time > TimeSerial(9, 0, 0) Then
//!     ' More reliable
//! End If
//! ```
//!
//! ### 3. Colons in File Names
//!
//! ```vb6
//! ' Invalid filename on Windows (colons not allowed)
//! fileName = "log_" & Time$ & ".txt"  ' "log_14:30:45.txt" - ERROR!
//!
//! ' Remove or replace colons
//! fileName = "log_" & Replace$(Time$, ":", "") & ".txt"  ' "log_143045.txt"
//! fileName = "log_" & Replace$(Time$, ":", "-") & ".txt"  ' "log_14-30-45.txt"
//! ```
//!
//! ### 4. Time Changes During Execution
//!
//! ```vb6
//! ' Problem: time can change between calls
//! Debug.Print "Start: " & Time$
//! ' ... long operation ...
//! Debug.Print "End: " & Time$  ' Different value!
//!
//! ' Solution: capture at start if consistency needed
//! Dim operationTime As String
//! operationTime = Time$
//! Debug.Print "Start: " & operationTime
//! ' ... long operation ...
//! Debug.Print "Started at: " & operationTime
//! Debug.Print "Completed at: " & Time$
//! ```
//!
//! ### 5. No Milliseconds
//!
//! ```vb6
//! ' Time$ only has second precision
//! Debug.Print Time$  ' "14:30:45" (no milliseconds)
//!
//! ' For higher precision, use Timer function
//! Dim startTimer As Single
//! startTimer = Timer
//! ' ... operation ...
//! Debug.Print "Elapsed: " & (Timer - startTimer) & " seconds"
//! ```
//!
//! ### 6. Locale Independence
//!
//! ```vb6
//! ' Time$ format is NOT affected by locale settings
//! ' Always returns "HH:MM:SS" regardless of system locale
//! Debug.Print Time$  ' Always "14:30:45" format
//!
//! ' For locale-specific formatting, use Format$
//! Debug.Print Format$(Now, "Long Time")  ' Respects locale
//! ```
//!
//! ## Practical Examples
//!
//! ### Creating Log Files with Timestamps
//!
//! ```vb6
//! Sub WriteLog(message As String)
//!     Dim logFile As String
//!     Dim timeStamp As String
//!     
//!     logFile = App.Path & "\application.log"
//!     timeStamp = Date$ & " " & Time$
//!     
//!     Open logFile For Append As #1
//!     Print #1, timeStamp & " - " & message
//!     Close #1
//! End Sub
//! ```
//!
//! ### Digital Clock Display
//!
//! ```vb6
//! Private Sub tmrClock_Timer()
//!     lblClock.Caption = Time$
//!     
//!     ' Update every second
//!     tmrClock.Interval = 1000
//! End Sub
//! ```
//!
//! ### Performance Monitoring
//!
//! ```vb6
//! Sub MonitorPerformance()
//!     Dim startTime As Double
//!     Dim endTime As Double
//!     
//!     Debug.Print "Operation started at: " & Time$
//!     startTime = Timer
//!     
//!     ' ... operation to monitor ...
//!     
//!     endTime = Timer
//!     Debug.Print "Operation ended at: " & Time$
//!     Debug.Print "Elapsed time: " & (endTime - startTime) & " seconds"
//! End Sub
//! ```
//!
//! ### Scheduled Task Execution
//!
//! ```vb6
//! Private Sub tmrScheduler_Timer()
//!     Dim currentTimeStr As String
//!     currentTimeStr = Time$
//!     
//!     Select Case currentTimeStr
//!         Case "09:00:00"
//!             RunMorningReport
//!         Case "12:00:00"
//!             RunNoonBackup
//!         Case "17:00:00"
//!             RunEveningCleanup
//!     End Select
//! End Sub
//! ```
//!
//! ## Limitations
//!
//! - Always returns 24-hour format (no AM/PM)
//! - No millisecond or sub-second precision
//! - No time zone information
//! - Format cannot be customized (use `Format$` for that)
//! - Returns string, not suitable for time arithmetic (use `Time` function instead)
//! - Colons in output make it unsuitable for filenames without modification
//! - Cannot be set (read-only; use `Time =` statement to set system time)

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

    #[test]
    fn time_dollar_simple() {
        let source = r"
Sub Main()
    result = Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_assignment() {
        let source = r"
Sub Main()
    Dim currentTime As String
    currentTime = Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_display() {
        let source = r#"
Sub ShowTime()
    Debug.Print "Current time: " & Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_logging() {
        let source = r#"
Sub LogMessage(message As String)
    Dim logEntry As String
    logEntry = Time$ & " - " & message
    Debug.Print logEntry
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_file_naming() {
        let source = r#"
Function GenerateFileName(baseName As String) As String
    Dim timeStamp As String
    timeStamp = Replace$(Time$, ":", "")
    GenerateFileName = baseName & "_" & timeStamp & ".log"
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_in_condition() {
        let source = r#"
Sub Main()
    If Time$ = "09:00:00" Then
        Debug.Print "Morning task"
    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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_timer_update() {
        let source = r"
Sub Timer1_Timer()
    lblTime.Caption = Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_with_date() {
        let source = r#"
Function GetFullTimestamp() As String
    GetFullTimestamp = Date$ & " " & Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_processing_time() {
        let source = r#"
Sub ProcessData()
    Dim startTime As String
    startTime = Time$
    Debug.Print "Started at: " & startTime
    Debug.Print "Completed at: " & Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_multiple_uses() {
        let source = r"
Sub RecordActivity()
    Dim time1 As String
    Dim time2 As String
    time1 = Time$
    time2 = Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_select_case() {
        let source = r#"
Sub CheckTime()
    Select Case Time$
        Case "09:00:00"
            RunMorningTask
        Case "17:00:00"
            RunEveningTask
    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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_audit_trail() {
        let source = r#"
Sub RecordAudit(action As String, userName As String)
    Dim auditEntry As String
    auditEntry = Date$ & " " & Time$ & " - " & userName & " - " & action
    Print #1, auditEntry
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_status_bar() {
        let source = r#"
Sub UpdateStatusBar()
    StatusBar1.Panels(1).Text = "Current Time: " & Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_debug_log() {
        let source = r#"
Sub DebugLog(category As String, message As String)
    Debug.Print "[" & Time$ & "] " & category & ": " & message
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_in_function() {
        let source = r"
Function GetCurrentTime() As String
    GetCurrentTime = Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_greeting() {
        let source = r#"
Function GetGreeting() As String
    GetGreeting = "Good morning! Time: " & Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_log_file() {
        let source = r#"
Sub WriteLog(message As String)
    Dim timeStamp As String
    timeStamp = Date$ & " " & Time$
    Print #1, timeStamp & " - " & message
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_loop_processing() {
        let source = r#"
Sub ProcessItems()
    Dim i As Integer
    Dim currentTimeStr As String
    currentTimeStr = Time$
    For i = 1 To 10
        Debug.Print currentTimeStr & " - Item " & i
    Next 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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_concatenation() {
        let source = r#"
Sub Main()
    Dim output As String
    output = "Time is: " & Time$
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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn time_dollar_scheduler() {
        let source = r#"
Sub CheckSchedule()
    Dim timeCheck As String
    timeCheck = Time$
    If timeCheck >= "09:00:00" Then
        RunScheduledTask
    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/time_dollar",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }
}