macOS battery manufacturedate

Tried to find out the manufacturing date of my MacBook Pro’s battery. Turns out this was a non-trivial exercise, and I spent several hours on it. Worth documenting the process.

manufactureDate in macOS Mojave 10.14

Finding the right command to output battery info was easy enough:
ioreg -b -w 0 -f -r -c AppleSmartBattery

However, instead of a timestamp as I would have expected, the manufacturing date is output as:

"ManufactureDate" = nnnnn

Where nnnnn was a five digit integer that didn’t resemble any known timestamp format.

After some research, it turns out this date conforms to the Smart Battery Data Specification, which specifies:

The date is packed in the following fashion: (year-1980) * 512 + month * 32 + day

Or in bitwise form:

bits 0-4 — day
bits 5-8 — month
bits 9-15 — years since 1980

A quick bit of bitwise ops in bash:
d=12345; echo $((1980+(0x7f & $d>>9)))-$((0x0f & ($d>>5)))-$((0x1f & $d))

2004-1-25

Simply replace d with the five-digit integer shown in ioreg.

manufactureDate in macOS Big Sur 11

With another laptop on Big Sur, however, I could not figure out the new manufactureDate format. The value is now a very large integer (much longer than 5 digits, and looks to be at least 46-bits), but does not conform to any timestamp format that I know of, and I can longer find any specification that refers to this format.

Possible workaround

Right beside the ManufactureDate in ioreg is the serial number for the battery, which, at this point, is still meaningful (though Apple is about to start randomizing serial numbers). According to some Internet research, the fourth through seventh characters of serial encode the manufactureDate.

XXX8392XXXXXXXXXX

  • The fourth character in the sequence is the ending digit of the manufacturing year – e.g. 8 is 2018 (or 2028, or 2008…)
  • The fifth and sixth characters encode the manufacturing week of the year – e.g. 39 is the 39th week, which in 2018 is Sept 23 according to Wolfram Alpha
  • The seventh character encodes the day offset – e.g. 2 is +2 days from the start of the week, Sept 25, 2018

Wouldn’t it be so much easier if Apple just used ISO date stamps? Why the hassle?