Skip to content

Commit

Permalink
iso
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmcdonald3 committed Aug 9, 2024
1 parent 6c3e6d2 commit d1e38cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@

public class AwsSdkCodegenConstants {
public static String AWS_SDK_CODEGEN_SYMBOLWRITER_DUMP_FILE_FILENAME = "awssdk_codegen_todelete.tmp";

// boto3 models `Timestamp` Smithy objects as `datetime.datetime` objects
// with millisecond precision masquerading as microsecond precision;
// e.x. datetime.datetime(2024, 6, 14, 16, 40, 15, 761000, tzinfo=tzlocal())
// --> 761000 is actually just 761 ms, but boto3 reports it with microsecond precision.
public static String BOTO3_TIMESTAMP_STRING_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ";
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,8 @@ public String enumShape(EnumShape shape) {
@Override
public String timestampShape(TimestampShape shape) {
writer.addStdlibImport("_dafny");
writer.addStdlibImport("datetime", "timezone");
return "_dafny.Seq(%1$s.astimezone(timezone.utc).strftime(\"%2$s\"))".formatted(
dataSource,
BOTO3_TIMESTAMP_STRING_FORMAT
return "_dafny.Seq(%1$s.isoformat())".formatted(
dataSource
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ public String enumShape(EnumShape shape) {
@Override
public String timestampShape(TimestampShape shape) {
writer.addStdlibImport("datetime", "datetime");
return "datetime.strptime(%1$s.VerbatimString(False), \"%2$s\")".formatted(
dataSource,
BOTO3_TIMESTAMP_STRING_FORMAT
return "datetime.fromisoformat(%1$s.VerbatimString(False))".formatted(
dataSource
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,10 @@ public String enumShape(EnumShape shape) {
);
}

@Override
public String timestampShape(TimestampShape shape) {
writer.addStdlibImport("_dafny");
return "_dafny.Seq(%1$s.isoformat())".formatted(
dataSource
);
}
@Override
public String timestampShape(TimestampShape shape) {
throw new UnsupportedOperationException("TimestampShape from within a LocalService not supported");
}

@Override
public String unionShape(UnionShape unionShape) {
Expand Down

0 comments on commit d1e38cb

Please sign in to comment.