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?

1 Reply to “macOS battery manufacturedate”

  1. Hi,

    I have a solution for this post-serial-randomisation.

    The ManufactureDate value is a 48-bit value.
    Convert that to hex, you’ll get something of the form 0x3a3b3c3d3e3f (where a-f are all digits, not A-F hex).
    That looks familiar… it’s ASCII-encoded digits!
    You can hex decode, or just cheat and grab every second character (ie abcdef)
    Next, reverse them – fedcba
    fe = year, offset from a base of 1992 (don’t ask me why they picked 1992…)
    dc = month
    ba = day

    So, for example, a ManufactureDate of 54083103764787 becomes 0x313034303133, which is “104013”, reverse that to get 310401. 1992+31=2023, so the decoded date value is 2023-04-01

    It seems to work for MacBooks going back at least 5 years, so I was able to compare against the serialnumber method for older units, and for new ones it’s pretty close to what CoconutBattery reports (I have no idea how they do it).

    I explained a bit better on a GitHub issue – https://github.com/munkireport/power/issues/26

Leave a Reply

Your email address will not be published. Required fields are marked *