Skip to content

Commit 8b8d850

Browse files
committed
Fix format string discrepancy between ctime and asctime
1 parent 6ce3328 commit 8b8d850

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
public final class TimeModuleBuiltins extends PythonBuiltins {
8888
private static final int DELAY_NANOS = 10;
8989
private static final long PERF_COUNTER_START = TruffleOptions.AOT ? 0 : System.nanoTime();
90+
private static final String CTIME_FORMAT = "%s %s %2d %02d:%02d:%02d %d";
9091

9192
@Override
9293
protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFactories() {
@@ -850,16 +851,14 @@ private static long op(int[] integers) {
850851
@GenerateNodeFactory
851852
public abstract static class CTimeNode extends PythonBuiltinNode {
852853

853-
private static final String FORMAT = "%s %s %2d %02d:%02d:%02d %d";
854-
855854
@Specialization
856855
public String localtime(VirtualFrame frame, Object seconds,
857856
@Cached ToLongTime toLongTime) {
858857
return format(getIntLocalTimeStruct(toLongTime.execute(frame, seconds)));
859858
}
860859

861860
protected static String format(int[] tm) {
862-
return ASCTimeNode.format(FORMAT, tm);
861+
return ASCTimeNode.format(CTIME_FORMAT, tm);
863862
}
864863
}
865864

@@ -868,7 +867,6 @@ protected static String format(int[] tm) {
868867
@GenerateNodeFactory
869868
public abstract static class ASCTimeNode extends PythonBuiltinNode {
870869

871-
private static final String FORMAT = "%s %s %02d %02d:%02d:%02d %d";
872870
static final String[] WDAY_NAME = new String[]{
873871
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
874872
};
@@ -892,7 +890,7 @@ public String localtime(PTuple time,
892890
}
893891

894892
protected static String format(int[] tm) {
895-
return format(FORMAT, tm);
893+
return format(CTIME_FORMAT, tm);
896894
}
897895

898896
@TruffleBoundary

0 commit comments

Comments
 (0)