Skip to content

Commit

Permalink
Fixed linting and style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
prithvisingh18 committed Mar 1, 2018
1 parent ef658d7 commit da55602
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions python/common/python/time.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,27 @@ public static org.python.Object clock() {
}

@org.python.Method(
__doc__ = "ctime(seconds) -> string\n\n"+
"Convert a time in seconds since the Epoch to a string in local time.\n"+
"This is equivalent to asctime(localtime(seconds)). When the time tuple is\n"+
__doc__ = "ctime(seconds) -> string\n\n" +
"Convert a time in seconds since the Epoch to a string in local time.\n" +
"This is equivalent to asctime(localtime(seconds)). When the time tuple is\n" +
"not present, current time as returned by localtime() is used.",
default_args = {"seconds"}
)
public static org.python.Object ctime(org.python.Object seconds) {
java.util.Date date;
if(seconds == null){
if (seconds == null) {
long currentTimeInMillis = System.currentTimeMillis();
date = new java.util.Date(currentTimeInMillis);
} else {
date = new java.util.Date(((org.python.types.Int) seconds.__int__()).value * 1000L);
}
java.text.SimpleDateFormat ft = new java.text.SimpleDateFormat("E MMM dd HH:mm:ss yyyy");
String padded_date = ft.format(date);
if(Character.toString(padded_date.charAt(8)).equals("0")) {
if (Character.toString(padded_date.charAt(8)).equals("0")) {
java.lang.StringBuilder sb = new StringBuilder();
sb.append(padded_date.substring(0,7));
sb.append(padded_date.substring(0, 7));
sb.append(" ");
sb.append(padded_date.substring(9,padded_date.length()));
sb.append(padded_date.substring(9, padded_date.length()));
padded_date = sb.toString();
}
return new org.python.types.Str(padded_date);
Expand Down
1 change: 1 addition & 0 deletions tests/stdlib/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def test_ctime(self):
import time
print(time.ctime()[:10], time.ctime()[-4:])
""")

def test_ctime_with_parameter(self):
self.assertCodeExecution("""
import time
Expand Down

0 comments on commit da55602

Please sign in to comment.