32

For a simple app I'm using to test a devops pipeline I'm outputting the start time of a build to the homepage. On my development machine the year of the ISO-8601 timestamp I expect, 2019, is printed (specifically, "2019-09-12T20:11:00.000Z"). When the same codebase is built using AWS CodeBuild the ISO-8601 timestamp looks like "+051668-02-09T08:09:32.000Z". What is "+051668"? I presume it's the year; My best guess is it's the year represented as a different calendar. Thoughts?

AWS CodeBuild sets this environment variable for every build (CODEBUILD_START_TIME). I'm building with their latest, default, Ubuntu container (v2.0).

trycrmr
  • 443
  • 4
  • 8
  • 1
    @AuxTaco wow, guess this is wrong/incomplete then? https://i.imgur.com/LgnmacQ.png , deleted my comment – hanshenrik Sep 14 '19 at 08:54
  • 1
    @hanshenrik That grammar doesn't appear to allow for five-digit years at all. I hesitate to say it's *wrong*, since expanded years are "only allowed by mutual agreement of the partners in information interchange." – AuxTaco Sep 14 '19 at 09:28

1 Answers1

67

Most of the google hits show CODEBUILD_START_TIME being represented as the number of milliseconds since 1970. I suspect somewhere in your code you are treating that as if it were seconds.

If you convert +051668-02-09T08:09:32.000Z to seconds you get 1568320819772. If you divide+round that by 1000 you get 1568320819 then convert that back to a human readable time you get September 12, 2019 8:40:19.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • 4
    Yep, test data was a unix timestamp in seconds! Thought I had grabbed that timestamp directly from CodeBuild logs, but guess not. – trycrmr Sep 12 '19 at 23:11
  • 10
    Bad docs too; Amazon just says "the start time of the build" – Lightness Races in Orbit Sep 13 '19 at 12:30
  • 4
    Provided some feedback for the docs to be more specific about the timestamp via the link in the bottom right https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html . – trycrmr Sep 13 '19 at 14:23