<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > BuiltIn Functions > Date and Time > cDateTime > cDateTime_Methods > <cDateTime>.Copy |
Description
Performs shallow copy of data from cDateTime to other cDateTime.
Syntax
<cDateTime>.Copy(sourceObject)
Returns
None.
Parameters
Name |
Type |
Optional |
Meaning |
sourceObject |
cDateTime |
No |
Another cDateTime object |
Remarks
Please note that shallow copy means that any change you do to the source object will be visible in the target object.
Also, any change made to target object will be applied to source object!
Restrictions
See also
Examples
' Create an object with current date and time
Dim firstDateTime As New cDateTime
' Set its values
firstDateTime.NewDate(2020, 12, 24)
firstDateTime.NewTime(20, 0, 0)
' Create another object with current date and time
Dim secondDateTime As New cDateTime
' Copy from firstDateTime - please note secondDateTime had to be initialized via NEW
secondDateTime.Copy(firstDateTime)
' Now both firstDateTime and secondDateTime represent the same date & time
MsgBox 0, firstDateTime.toString + "=" + secondDateTime.toString
secondDateTime.AddHours(5)
' Now you can see both source and target object are modified!
MsgBox 0, firstDateTime.toString + "=" + secondDateTime.toString