I'm sure that it's not day and night, as you can get both at the same time. However this misconception is very common (I thought that it's day/night at first too) because Beautifly learns morning sun and Dustox learns moonlight, leading us to think of Beautifly as day and Dustox as night.
Gender is also impossible, as you CAN get male and female Beautiflies. You can prove this by finding both male and female silcoons, male and female cascoons. Gender is out of the picture. All semi-accurate pokedexes online will tell you that there's 50% for both gender for both Beautifly and Dustox.
This leaves us with personality values and EVs left as they are the only numbers left. EV is manipulated, so it cannot be EV. All we're left with is personality values, and controlling that is impossible, so we can just say "it's random."
Testing with Wurmple for evolution is OFTEN inaccurate, such as the many claims made in this thread. This is because there are too many personality value combinations (31 to the power of 6 = 887503681). Out of all those massive amounts of possible combinations, 443751841 of those combinations will result in Beautifly, and the others in Dustox. You can easily catch 20 male Wurmples that satisfy one out of the 44375184 possible combinations to get yourself a Beautifly.
This is the reason why all this Wurmple matter vary from site to site. How can you "test" it out? You won't find a unified answer. The only way to find this is to hack into the game itself and see what's the determining factor, which is what Meowth has done.