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. Lets poll no matter what time of the day

Lets poll no matter what time of the day

Scheduled Pinned Locked Moved The Weird and The Wonderful
5 Posts 5 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.
  • V Offline
    V Offline
    virang_21
    wrote on last edited by
    #1

    public static bool checkPolTime(string SFDCStartTime)
    {
    string configSFDCStartTime = string.Empty;
    string configSFDCAMPM = string.Empty;
    int len = 0;
    len = SFDCStartTime.Length;
    //Reading from Config File
    if (len > 7)
    {
    configSFDCStartTime = SFDCStartTime.Substring(0, 5);
    configSFDCAMPM = SFDCStartTime.Substring(6, 2);
    }
    else
    {
    configSFDCStartTime = SFDCStartTime.Substring(0, 4);
    configSFDCAMPM = SFDCStartTime.Substring(5, 2);
    }

           //Reading System Time
           string systemSFDCStartMin = string.Empty;
           string systemSFDCStartSec = string.Empty;
           string systemSFDCAMPM = string.Empty;
    
           string time = DateTime.Now.ToString();
           string\[\] splitchr = { " " };
           string\[\] strarr = time.Split(splitchr, StringSplitOptions.None);
           string s = strarr\[0\];
           len = s.Length;
    
           if (len == 9)
           {
               splitchr\[0\] = ":";
               strarr = time.Split(splitchr, StringSplitOptions.None);
               s = strarr\[0\];
               len = s.Length;
    
               if (len == 11)
               {
                   systemSFDCStartMin = time.Substring(10, 4);
                   systemSFDCStartSec = time.Substring(15, 2);
                   systemSFDCAMPM = time.Substring(18, 2);
               }
               else if (len == 12)
               {
                   systemSFDCStartMin = time.Substring(10, 5);
                   systemSFDCStartSec = time.Substring(16, 2);
                   systemSFDCAMPM = time.Substring(19, 2);
               }
           }
           else if (len == 10)
           {
               splitchr\[0\] = ":";
               strarr = time.Split(splitchr, StringSplitOptions.None);
               s = strarr\[0\];
               len = s.Length;
    
               if (len == 12)
               {
                   systemSFDCStartMin = time.Substring(11, 4);
                   systemSFDCStartSec = time.Substring(16, 2);
                   systemSFDCAMPM = time.Substring(19, 2);
               }
               else if (len == 13)
               {
                   systemSFDCStartMin = time.Substring(11, 5);
                   systemSFDCStartSec = time.Substring(17, 2);
                   systemSFDCAMPM = time.Substrin
    
    B Kornfeld Eliyahu PeterK OriginalGriffO L 4 Replies Last reply
    0
    • V virang_21

      public static bool checkPolTime(string SFDCStartTime)
      {
      string configSFDCStartTime = string.Empty;
      string configSFDCAMPM = string.Empty;
      int len = 0;
      len = SFDCStartTime.Length;
      //Reading from Config File
      if (len > 7)
      {
      configSFDCStartTime = SFDCStartTime.Substring(0, 5);
      configSFDCAMPM = SFDCStartTime.Substring(6, 2);
      }
      else
      {
      configSFDCStartTime = SFDCStartTime.Substring(0, 4);
      configSFDCAMPM = SFDCStartTime.Substring(5, 2);
      }

             //Reading System Time
             string systemSFDCStartMin = string.Empty;
             string systemSFDCStartSec = string.Empty;
             string systemSFDCAMPM = string.Empty;
      
             string time = DateTime.Now.ToString();
             string\[\] splitchr = { " " };
             string\[\] strarr = time.Split(splitchr, StringSplitOptions.None);
             string s = strarr\[0\];
             len = s.Length;
      
             if (len == 9)
             {
                 splitchr\[0\] = ":";
                 strarr = time.Split(splitchr, StringSplitOptions.None);
                 s = strarr\[0\];
                 len = s.Length;
      
                 if (len == 11)
                 {
                     systemSFDCStartMin = time.Substring(10, 4);
                     systemSFDCStartSec = time.Substring(15, 2);
                     systemSFDCAMPM = time.Substring(18, 2);
                 }
                 else if (len == 12)
                 {
                     systemSFDCStartMin = time.Substring(10, 5);
                     systemSFDCStartSec = time.Substring(16, 2);
                     systemSFDCAMPM = time.Substring(19, 2);
                 }
             }
             else if (len == 10)
             {
                 splitchr\[0\] = ":";
                 strarr = time.Split(splitchr, StringSplitOptions.None);
                 s = strarr\[0\];
                 len = s.Length;
      
                 if (len == 12)
                 {
                     systemSFDCStartMin = time.Substring(11, 4);
                     systemSFDCStartSec = time.Substring(16, 2);
                     systemSFDCAMPM = time.Substring(19, 2);
                 }
                 else if (len == 13)
                 {
                     systemSFDCStartMin = time.Substring(11, 5);
                     systemSFDCStartSec = time.Substring(17, 2);
                     systemSFDCAMPM = time.Substrin
      
      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      Your code snippet is not complete. You forgot e.g. systemSFDCStartHour and systemSFDCStartMilliSecond. Also code for non-American locales is missing. You can add several hundred lines more of useless code before that return true statement, there is a lot of space for future optimizations!

      1 Reply Last reply
      0
      • V virang_21

        public static bool checkPolTime(string SFDCStartTime)
        {
        string configSFDCStartTime = string.Empty;
        string configSFDCAMPM = string.Empty;
        int len = 0;
        len = SFDCStartTime.Length;
        //Reading from Config File
        if (len > 7)
        {
        configSFDCStartTime = SFDCStartTime.Substring(0, 5);
        configSFDCAMPM = SFDCStartTime.Substring(6, 2);
        }
        else
        {
        configSFDCStartTime = SFDCStartTime.Substring(0, 4);
        configSFDCAMPM = SFDCStartTime.Substring(5, 2);
        }

               //Reading System Time
               string systemSFDCStartMin = string.Empty;
               string systemSFDCStartSec = string.Empty;
               string systemSFDCAMPM = string.Empty;
        
               string time = DateTime.Now.ToString();
               string\[\] splitchr = { " " };
               string\[\] strarr = time.Split(splitchr, StringSplitOptions.None);
               string s = strarr\[0\];
               len = s.Length;
        
               if (len == 9)
               {
                   splitchr\[0\] = ":";
                   strarr = time.Split(splitchr, StringSplitOptions.None);
                   s = strarr\[0\];
                   len = s.Length;
        
                   if (len == 11)
                   {
                       systemSFDCStartMin = time.Substring(10, 4);
                       systemSFDCStartSec = time.Substring(15, 2);
                       systemSFDCAMPM = time.Substring(18, 2);
                   }
                   else if (len == 12)
                   {
                       systemSFDCStartMin = time.Substring(10, 5);
                       systemSFDCStartSec = time.Substring(16, 2);
                       systemSFDCAMPM = time.Substring(19, 2);
                   }
               }
               else if (len == 10)
               {
                   splitchr\[0\] = ":";
                   strarr = time.Split(splitchr, StringSplitOptions.None);
                   s = strarr\[0\];
                   len = s.Length;
        
                   if (len == 12)
                   {
                       systemSFDCStartMin = time.Substring(11, 4);
                       systemSFDCStartSec = time.Substring(16, 2);
                       systemSFDCAMPM = time.Substring(19, 2);
                   }
                   else if (len == 13)
                   {
                       systemSFDCStartMin = time.Substring(11, 5);
                       systemSFDCStartSec = time.Substring(17, 2);
                       systemSFDCAMPM = time.Substrin
        
        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu Peter
        wrote on last edited by
        #3

        The original plan was to finish the method while poll isn't active. It just never happened since...

        I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is (V).

        "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

        1 Reply Last reply
        0
        • V virang_21

          public static bool checkPolTime(string SFDCStartTime)
          {
          string configSFDCStartTime = string.Empty;
          string configSFDCAMPM = string.Empty;
          int len = 0;
          len = SFDCStartTime.Length;
          //Reading from Config File
          if (len > 7)
          {
          configSFDCStartTime = SFDCStartTime.Substring(0, 5);
          configSFDCAMPM = SFDCStartTime.Substring(6, 2);
          }
          else
          {
          configSFDCStartTime = SFDCStartTime.Substring(0, 4);
          configSFDCAMPM = SFDCStartTime.Substring(5, 2);
          }

                 //Reading System Time
                 string systemSFDCStartMin = string.Empty;
                 string systemSFDCStartSec = string.Empty;
                 string systemSFDCAMPM = string.Empty;
          
                 string time = DateTime.Now.ToString();
                 string\[\] splitchr = { " " };
                 string\[\] strarr = time.Split(splitchr, StringSplitOptions.None);
                 string s = strarr\[0\];
                 len = s.Length;
          
                 if (len == 9)
                 {
                     splitchr\[0\] = ":";
                     strarr = time.Split(splitchr, StringSplitOptions.None);
                     s = strarr\[0\];
                     len = s.Length;
          
                     if (len == 11)
                     {
                         systemSFDCStartMin = time.Substring(10, 4);
                         systemSFDCStartSec = time.Substring(15, 2);
                         systemSFDCAMPM = time.Substring(18, 2);
                     }
                     else if (len == 12)
                     {
                         systemSFDCStartMin = time.Substring(10, 5);
                         systemSFDCStartSec = time.Substring(16, 2);
                         systemSFDCAMPM = time.Substring(19, 2);
                     }
                 }
                 else if (len == 10)
                 {
                     splitchr\[0\] = ":";
                     strarr = time.Split(splitchr, StringSplitOptions.None);
                     s = strarr\[0\];
                     len = s.Length;
          
                     if (len == 12)
                     {
                         systemSFDCStartMin = time.Substring(11, 4);
                         systemSFDCStartSec = time.Substring(16, 2);
                         systemSFDCAMPM = time.Substring(19, 2);
                     }
                     else if (len == 13)
                     {
                         systemSFDCStartMin = time.Substring(11, 5);
                         systemSFDCStartSec = time.Substring(17, 2);
                         systemSFDCAMPM = time.Substrin
          
          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Nope, no redundant code in there, nope, none. Nothing to see here, move along...:TunelessWhistleSmiley:

          The only instant messaging I do involves my middle finger. English doesn't borrow from other languages. English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • V virang_21

            public static bool checkPolTime(string SFDCStartTime)
            {
            string configSFDCStartTime = string.Empty;
            string configSFDCAMPM = string.Empty;
            int len = 0;
            len = SFDCStartTime.Length;
            //Reading from Config File
            if (len > 7)
            {
            configSFDCStartTime = SFDCStartTime.Substring(0, 5);
            configSFDCAMPM = SFDCStartTime.Substring(6, 2);
            }
            else
            {
            configSFDCStartTime = SFDCStartTime.Substring(0, 4);
            configSFDCAMPM = SFDCStartTime.Substring(5, 2);
            }

                   //Reading System Time
                   string systemSFDCStartMin = string.Empty;
                   string systemSFDCStartSec = string.Empty;
                   string systemSFDCAMPM = string.Empty;
            
                   string time = DateTime.Now.ToString();
                   string\[\] splitchr = { " " };
                   string\[\] strarr = time.Split(splitchr, StringSplitOptions.None);
                   string s = strarr\[0\];
                   len = s.Length;
            
                   if (len == 9)
                   {
                       splitchr\[0\] = ":";
                       strarr = time.Split(splitchr, StringSplitOptions.None);
                       s = strarr\[0\];
                       len = s.Length;
            
                       if (len == 11)
                       {
                           systemSFDCStartMin = time.Substring(10, 4);
                           systemSFDCStartSec = time.Substring(15, 2);
                           systemSFDCAMPM = time.Substring(18, 2);
                       }
                       else if (len == 12)
                       {
                           systemSFDCStartMin = time.Substring(10, 5);
                           systemSFDCStartSec = time.Substring(16, 2);
                           systemSFDCAMPM = time.Substring(19, 2);
                       }
                   }
                   else if (len == 10)
                   {
                       splitchr\[0\] = ":";
                       strarr = time.Split(splitchr, StringSplitOptions.None);
                       s = strarr\[0\];
                       len = s.Length;
            
                       if (len == 12)
                       {
                           systemSFDCStartMin = time.Substring(11, 4);
                           systemSFDCStartSec = time.Substring(16, 2);
                           systemSFDCAMPM = time.Substring(19, 2);
                       }
                       else if (len == 13)
                       {
                           systemSFDCStartMin = time.Substring(11, 5);
                           systemSFDCStartSec = time.Substring(17, 2);
                           systemSFDCAMPM = time.Substrin
            
            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Maybe this function was designed as Sleep replacement?

            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