The 3DS CPU has something called a tick counter that acts like a count register. Every 2 CPU cycles the tick counter is incremented by 2. Since this counter is tied to CPU cycles, it is independent of any running application, so is unaffected by any lag in the game. When ever the game is running, it has a 8 byte (DWORD) variable starting at address 006B1E48. When ever the game is running (i.e. when not in the home menu or when the lid is closed), the change in the tick counter is added to the BA timer, in effect giving a measure how long the game has been played since it was last launched.
When you catch HSW in a bottle, all that matters is the item slot that the bottle is in. Based on this slot, the game determines where to write timer data for the HSW. One of the values that is written is the BA timer, and some other data that is constant. If any of the 7 bottles are real (ie one of the 7 bottle slots are used), then these values are stored in a region of memory meant for the HSW timers. If the bottle is duped (that is the item slot used is not one of the 7 bottles) then these values can be written outside of the memory region intended for the HSW timer, and depending on what specific address is written to can cause various effects.