xLeaves
10-09-2019, 15:21
I have enhanced and encapsulated FreeBasic's time library so that ThinBasic can use these functions.
Now they are integrated into the development environment of LzRPA.
I will post these programming code here.
So that people with the same needs can use them.
The code also includes the implementation of MsgBox, InputBox and keyboard and mouse emulation.
Also note that it covers some of the original ThinBasic functions and may cause compatibility issues.
Because I have no historical burden when developing with ThinBasic.
Consider less compatibility issues.
Below is a screenshot of the test code:
TracePrint("当前日期和时间 : " & Now())
TracePrint("当前日期 : " & Date())
TracePrint("当前时间 : " & Time())
TracePrint("时间戳 : " & Timer())
TracePrint("当前年 : " & Year())
TracePrint("当前月份 : " & Month())
TracePrint("当前日期 : " & Day())
TracePrint("当前星期几 : " & WeekDay())
TracePrint("当前时 : " & Hour())
TracePrint("当前分 : " & Minute())
TracePrint("当前秒 : " & Second())
TracePrint("当前Unix时间戳 : " & ToUnixTime())
TracePrint("十天后的Unix时间戳 : " & ToUnixTime(Now()))
TracePrint("将当前Unix时间戳转换为时间 : " & FromUnixTime(ToUnixTime(Now())))
TracePrint("判断是否可以转换为时间 : " & IsDate("2018年12月12日 12:00:00"))
TracePrint("将字符串转换为时间 : " & CDate("2018年12月12日 12:00:00"))
TracePrint("当前时间添加10天 : " & DateAdd("d", 10, Now()))
TracePrint("获取当天与十天后的时间差(返回天) : " & DateDiff("d", DateAdd("d", 10, Now()), Now()))
TracePrint("构造日期 : " & DateSerial(2019, 9, 4))
TracePrint("构造时间 : " & TimeSerial(12, 0, 0))
TracePrint("构造时间和日期 : " & TimeSerial(2019, 9, 4, 12, 0, 0))
TracePrint("获取时间中天这部分的数据 : " & DatePart("d", Now()))
TracePrint("将时间格式化显示 : " & Format(Now(), "yyyy-mm-dd hh:mm:ss"))
10029
FreeBasic's time library uses a Double data store time information, where the integer part stores the number of days (how many days have elapsed since a certain time) and the fractional part stores the time of day, for example, 0.5 means 12:00:00.
The advantage of this is that time can be directly added and subtracted, very convenient, the disadvantage is that you can not directly calculate and output the display like VB, you must first Format, otherwise they look like a bunch of meaningless numbers.
Of course, ThinBasic does not provide an operator overloading mechanism for data types, so output and computation cannot be done at the same time.
I think that the computing power of time is the most important, so I gave up the idea of reconstructing a time system. FreeBasic's time library is quite good.
But it's not quite complete, so I added four functions, ToUnixTime, FromUnixTime, IsDate, and CDate, to make this time library better.
Of course, the function is also closer to the processing power of VB.
Below is the source code, developed using FreeBasic (FbEdit editor):
10030
Now they are integrated into the development environment of LzRPA.
I will post these programming code here.
So that people with the same needs can use them.
The code also includes the implementation of MsgBox, InputBox and keyboard and mouse emulation.
Also note that it covers some of the original ThinBasic functions and may cause compatibility issues.
Because I have no historical burden when developing with ThinBasic.
Consider less compatibility issues.
Below is a screenshot of the test code:
TracePrint("当前日期和时间 : " & Now())
TracePrint("当前日期 : " & Date())
TracePrint("当前时间 : " & Time())
TracePrint("时间戳 : " & Timer())
TracePrint("当前年 : " & Year())
TracePrint("当前月份 : " & Month())
TracePrint("当前日期 : " & Day())
TracePrint("当前星期几 : " & WeekDay())
TracePrint("当前时 : " & Hour())
TracePrint("当前分 : " & Minute())
TracePrint("当前秒 : " & Second())
TracePrint("当前Unix时间戳 : " & ToUnixTime())
TracePrint("十天后的Unix时间戳 : " & ToUnixTime(Now()))
TracePrint("将当前Unix时间戳转换为时间 : " & FromUnixTime(ToUnixTime(Now())))
TracePrint("判断是否可以转换为时间 : " & IsDate("2018年12月12日 12:00:00"))
TracePrint("将字符串转换为时间 : " & CDate("2018年12月12日 12:00:00"))
TracePrint("当前时间添加10天 : " & DateAdd("d", 10, Now()))
TracePrint("获取当天与十天后的时间差(返回天) : " & DateDiff("d", DateAdd("d", 10, Now()), Now()))
TracePrint("构造日期 : " & DateSerial(2019, 9, 4))
TracePrint("构造时间 : " & TimeSerial(12, 0, 0))
TracePrint("构造时间和日期 : " & TimeSerial(2019, 9, 4, 12, 0, 0))
TracePrint("获取时间中天这部分的数据 : " & DatePart("d", Now()))
TracePrint("将时间格式化显示 : " & Format(Now(), "yyyy-mm-dd hh:mm:ss"))
10029
FreeBasic's time library uses a Double data store time information, where the integer part stores the number of days (how many days have elapsed since a certain time) and the fractional part stores the time of day, for example, 0.5 means 12:00:00.
The advantage of this is that time can be directly added and subtracted, very convenient, the disadvantage is that you can not directly calculate and output the display like VB, you must first Format, otherwise they look like a bunch of meaningless numbers.
Of course, ThinBasic does not provide an operator overloading mechanism for data types, so output and computation cannot be done at the same time.
I think that the computing power of time is the most important, so I gave up the idea of reconstructing a time system. FreeBasic's time library is quite good.
But it's not quite complete, so I added four functions, ToUnixTime, FromUnixTime, IsDate, and CDate, to make this time library better.
Of course, the function is also closer to the processing power of VB.
Below is the source code, developed using FreeBasic (FbEdit editor):
10030