help with creating function from snippit

If you now learn to properly indent (as mentioned above, use T in the IDE), it's a lot easier for us to help,

Anyway

void loop() {

  int TimeState ();

  ...
  ...

What do you expect the above to do? It's a function prototype (and does not belong there). If you want to call the function, use

void loop() {

  TimeState ();

  ...
  ...