Skip to content

Commit 3f38da4

Browse files
committed
dateToTime, boolToStr function
1 parent 291a586 commit 3f38da4

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.duy.pascal.compiler"
88
minSdkVersion rootProject.ext.minSdkVersion as Integer
99
targetSdkVersion rootProject.ext.targetSdkVersion as Integer
10-
versionCode 102
11-
versionName "4.0.2"
10+
versionCode 103
11+
versionName "4.0.3"
1212
vectorDrawables.useSupportLibrary = true
1313
multiDexEnabled true
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
Program TimeToStr;
1+
Program Example25;
22

3-
{ This program demonstrates the Time function }
3+
{ This program demonstrates the TimeToStr function }
44

55
Uses sysutils;
66

77
Begin
8-
Writeln ('The time is : ', TimeToStr(Time));
8+
Writeln ('The current time is : ',TimeToStr(Time));
99
End.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Program Example7;
2+
3+
{ This program demonstrates the DateToStr function }
4+
5+
Uses sysutils;
6+
7+
Begin
8+
Writeln(Format ('Today is: %s', [DateToStr(Date)]));
9+
End.

libCompiler/src/main/java/com/duy/pascal/backend/builtin_libraries/SysUtilsLibrary.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,22 @@ public StringBuilder format(StringBuilder format, Object[] arg) {
289289
@PascalMethod(description = "Convert a TDateTime time to a string using a predefined format")
290290
public StringBuilder timeToStr(Long time) {
291291
Date date = new Date(time);
292-
return new StringBuilder(date.toString());
292+
return new StringBuilder(date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());
293+
}
294+
295+
@PascalMethod(description = "Convert a TDateTime time to a string using a predefined format")
296+
public StringBuilder dateToStr(Long time) {
297+
Date date = new Date(time);
298+
return new StringBuilder(date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());
293299
}
294300

295301
@PascalMethod(description = "Returns the current time.")
296302
public Long time() {
297303
return System.currentTimeMillis();
298304
}
305+
306+
@PascalMethod(description = "Convert a boolean value to a string.")
307+
public StringBuilder boolToStr(Boolean b, StringBuilder sTrue, StringBuilder sFalse) {
308+
return b ? sTrue : sFalse;
309+
}
299310
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Program Example7;
2+
3+
{ This program demonstrates the DateToStr function }
4+
5+
Uses sysutils;
6+
7+
Begin
8+
Writeln(Format ('Today is: %s', [DateToStr(Date)]));
9+
End.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Program Example25;
2+
3+
{ This program demonstrates the TimeToStr function }
4+
5+
Uses sysutils;
6+
7+
Begin
8+
Writeln ('The current time is : ',TimeToStr(Time));
9+
End.

0 commit comments

Comments
 (0)