Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. A function for every minute of the day...

A function for every minute of the day...

Scheduled Pinned Locked Moved The Weird and The Wonderful
ruby
16 Posts 10 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnsyd
    wrote on last edited by
    #1

    Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

    P R C C T 8 Replies Last reply
    0
    • J johnsyd

      Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      So what did you do?

      private static readonly O932 = new System.DateTime ( 9 , 32 , 00 ) ;

      ...

      private bool IsBefore932()
      {
      return ( System.DateTime.Now.TimeOfDay <= O932 ) ;
      }

      (Or something like that, only better.)

      R J 2 Replies Last reply
      0
      • P PIEBALDconsult

        So what did you do?

        private static readonly O932 = new System.DateTime ( 9 , 32 , 00 ) ;

        ...

        private bool IsBefore932()
        {
        return ( System.DateTime.Now.TimeOfDay <= O932 ) ;
        }

        (Or something like that, only better.)

        R Offline
        R Offline
        Ri Qen Sin
        wrote on last edited by
        #3

        Compiler error! Wait… is that a zero or the letter O?

        So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?

        P 1 Reply Last reply
        0
        • P PIEBALDconsult

          So what did you do?

          private static readonly O932 = new System.DateTime ( 9 , 32 , 00 ) ;

          ...

          private bool IsBefore932()
          {
          return ( System.DateTime.Now.TimeOfDay <= O932 ) ;
          }

          (Or something like that, only better.)

          J Offline
          J Offline
          johnsyd
          wrote on last edited by
          #4

          You could have a lot of fun coming up with variations on the same theme! It's still there in production - I suspect we left it because it is too funny to lose.

          1 Reply Last reply
          0
          • R Ri Qen Sin

            Compiler error! Wait… is that a zero or the letter O?

            So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            The letter O, of course. :-D

            A 1 Reply Last reply
            0
            • J johnsyd

              Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

              R Offline
              R Offline
              Ri Qen Sin
              wrote on last edited by
              #6

              Gems like this is the reason I don't buy commercial ready-to-use components or libraries unless I can see the source code myself. :doh:

              So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?

              1 Reply Last reply
              0
              • J johnsyd

                Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                At least... does its job! :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                1 Reply Last reply
                0
                • J johnsyd

                  Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

                  C Offline
                  C Offline
                  Chris Maunder
                  wrote on last edited by
                  #8

                  I would love to see the specs for that particular case.

                  cheers, Chris Maunder

                  CodeProject.com : C++ MVP

                  J 1 Reply Last reply
                  0
                  • J johnsyd

                    Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

                    T Offline
                    T Offline
                    The Nightcoder
                    wrote on last edited by
                    #9

                    If it's stupid but it works, it isn't stupid. Then again...

                    Peter the small turnip (1) It Has To Work. --RFC 1925[^]

                    1 Reply Last reply
                    0
                    • J johnsyd

                      Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

                      T Offline
                      T Offline
                      The Cake of Deceit
                      wrote on last edited by
                      #10

                      I think they call that method every morning. :)

                      I'd been called 'ugly', 'pug ugly', 'fugly', 'pug fugly' but never 'ugly ugly'. - Moe Szyslak

                      1 Reply Last reply
                      0
                      • C Chris Maunder

                        I would love to see the specs for that particular case.

                        cheers, Chris Maunder

                        CodeProject.com : C++ MVP

                        J Offline
                        J Offline
                        johnsyd
                        wrote on last edited by
                        #11

                        It's part of a real-time application with tasks that are interdependent with tasks performed by many other apps running over several networks. 9:32 was the start time for a group of tasks it needed to do. It's actually an upgrade from the now deprecated function IsBefore928() :-) We know the maximum time each task takes to complete, so we can use cutoff times as a simple way to coordinate tasks between different machines on different networks without them having to know anything about each other. A settings file for the task start/stop times would be better. But to be fair, as a couple of guys have pointed out here, it does what it is supposed to!

                        1 Reply Last reply
                        0
                        • P PIEBALDconsult

                          The letter O, of course. :-D

                          A Offline
                          A Offline
                          Anthony Mushrow
                          wrote on last edited by
                          #12

                          It wasn't and you know it ;P

                          My current favourite word is: I'm starting to run out of fav. words!

                          -SK Genius

                          Game Programming articles start -here[^]-

                          P 1 Reply Last reply
                          0
                          • J johnsyd

                            Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

                            M Offline
                            M Offline
                            MarkB777
                            wrote on last edited by
                            #13

                            Yea, alot of unneccesary code there.

                            Mark Brock Click here to view my blog

                            1 Reply Last reply
                            0
                            • A Anthony Mushrow

                              It wasn't and you know it ;P

                              My current favourite word is: I'm starting to run out of fav. words!

                              -SK Genius

                              Game Programming articles start -here[^]-

                              P Offline
                              P Offline
                              PIEBALDconsult
                              wrote on last edited by
                              #14

                              O0O0O0

                              O0O0O0... huh, I thought it was. I know I meant it to be, but the pre they look the same. What kind of second-rate joint is this? I'm going to the suggestion forum next.

                              A 1 Reply Last reply
                              0
                              • P PIEBALDconsult

                                O0O0O0

                                O0O0O0... huh, I thought it was. I know I meant it to be, but the pre they look the same. What kind of second-rate joint is this? I'm going to the suggestion forum next.

                                A Offline
                                A Offline
                                Anthony Mushrow
                                wrote on last edited by
                                #15

                                Actually I think it is an Oh. BUt like you said, they look the same. It's terrible, it's a disgrace, it's, it's... I don't really care anymore.

                                My current favourite word is: I'm starting to run out of fav. words!

                                -SK Genius

                                Game Programming articles start -here[^]-

                                1 Reply Last reply
                                0
                                • J johnsyd

                                  Found this little gem in one of our apps at work ... // A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }

                                  A Offline
                                  A Offline
                                  Andy Brummer
                                  wrote on last edited by
                                  #16

                                  I hope you have unit tests with 100% code coverage for each one of those methods.

                                  I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups