I think it uses the context to figure out which to use. If the format string is a single character, it assumes it is a standard format. If it's a series of characters, it assumes d means day number.
That doesn't mean it always does something sensible. If you use the string "yd" it displays the two-digit year and the day number. For today, it gives 1127. Because it's not a single character formatting string, it assumes d means day number. That doesn't mean this is a value you would find useful.
Other formatting characters can give other sometimes confusing results depending on the context.