PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Round to nearest Multiple? NumericUpDown Question.
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Round to nearest Multiple? NumericUpDown Question.
![]() |
Round to nearest Multiple? NumericUpDown Question. |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Sorry, a bit new at this CF.
I'm looking for a function that will allow me round the min from a now() function to the nearest 15. So for example if it's 9:31 I would like it to return 30 i've got TimeID set as a string: TimeId = FormatDateTime(Now(), DateFormat.ShortTime) which is working fine. and using mid or right am able to get the min separated, but the rounding functions seem to just round to whole numbers. I'd be fine with a floor or ceiling command too, so that 9:31 would return either 30 or 45. I'm using a numericupdown to get the user of the form to input time in increments of 15min. And I guess since I'm on the topic is there anyway to make a NumericUpDown control flip? Using my original example. if I'm at 45 and press up I'd like it to revert back to 00. thanks in advance |
|
|
|
#2 |
|
Guest
Posts: n/a
|
ahem. i found a workaround solution. i'll post it in case anyone else
ever needs it MinInt is the cint(right(TimeId,2) Multiple is the Multiple you are interested in rounding too (in my case 15) MinRound = Math.Round(MinInt / Multiple) * Mutiple Mark wrote: > Sorry, a bit new at this CF. > > I'm looking for a function that will allow me round the min from a > now() function to the nearest 15. > > So for example if it's 9:31 I would like it to return 30 > > i've got TimeID set as a string: > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) > > which is working fine. and using mid or right am able to get the min > separated, but the rounding functions seem to just round to whole > numbers. > I'd be fine with a floor or ceiling command too, so that 9:31 would > return either 30 or 45. > I'm using a numericupdown to get the user of the form to input time in > increments of 15min. > > And I guess since I'm on the topic is there anyway to make a > NumericUpDown control flip? > Using my original example. if I'm at 45 and press up I'd like it to > revert back to 00. > > thanks in advance |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Just do it yourself. Note that your rounding scheme doesn't round to the
nearest, but it's very easy to handle that: ----- // Get the data from the text box. This is entered as a minutes value, more or less like // what you'd see from the DateTime.Now. Int32 min = Int32.Parse(textBox1.Text); // Round the minutes to the nearest 15. I get the number of 15 minute increments near // the minutes value here. One, the nearest 15 minute increment below and the other // above. Int32 inc = min / 15; Int32 inc1 = inc + 1; Int32 nearest; Int32 extrahour = 0; // Select the right increment. if (min - inc * 15 < inc1 * 15 - min) { nearest = inc * 15; } else { nearest = inc1 * 15; } // Now, you have to handle the case where the minutes are 60, since that doesn't make // sense if (nearest == 60) { nearest = 0; extrahour = 1; } // Show the minutes number and the extra hour that you need to add to your time (note that // this may also cause a wrap to the day, etc., so you have to handle that, too, to really have // a solution. label1.Text = nearest.ToString(); label2.Text = extrahour.ToString(); ----- Paul T. "Mark" <reeldeal81@gmail.com> wrote in message news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... > Sorry, a bit new at this CF. > > I'm looking for a function that will allow me round the min from a > now() function to the nearest 15. > > So for example if it's 9:31 I would like it to return 30 > > i've got TimeID set as a string: > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) > > which is working fine. and using mid or right am able to get the min > separated, but the rounding functions seem to just round to whole > numbers. > I'd be fine with a floor or ceiling command too, so that 9:31 would > return either 30 or 45. > I'm using a numericupdown to get the user of the form to input time in > increments of 15min. > > And I guess since I'm on the topic is there anyway to make a > NumericUpDown control flip? > Using my original example. if I'm at 45 and press up I'd like it to > revert back to 00. > > thanks in advance |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Any idea why my now() statement is returning a time an hour in
advance? my windows time is correct, is their a regional setting with vs.net that could be out of whack? On Apr 17, 10:14 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com> wrote: > Just do it yourself. Note that your rounding scheme doesn't round to the > nearest, but it's very easy to handle that: > > ----- > > // Get the data from the text box. This is entered as a minutes value, more > or less like > > // what you'd see from the DateTime.Now. > > Int32 min = Int32.Parse(textBox1.Text); > > // Round the minutes to the nearest 15. I get the number of 15 minute > increments near > > // the minutes value here. One, the nearest 15 minute increment below and > the other > > // above. > > Int32 inc = min / 15; > > Int32 inc1 = inc + 1; > > Int32 nearest; > > Int32 extrahour = 0; > > // Select the right increment. > > if (min - inc * 15 < inc1 * 15 - min) > > { > > nearest = inc * 15; > > } > > else > > { > > nearest = inc1 * 15; > > } > > // Now, you have to handle the case where the minutes are 60, since that > doesn't make > > // sense > > if (nearest == 60) > > { > > nearest = 0; > > extrahour = 1; > > } > > // Show the minutes number and the extra hour that you need to add to your > time (note that > > // this may also cause a wrap to the day, etc., so you have to handle that, > too, to really have > > // a solution. > > label1.Text = nearest.ToString(); > > label2.Text = extrahour.ToString(); > > ----- > > Paul T. > > "Mark" <reeldea...@gmail.com> wrote in message > > news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... > > > Sorry, a bit new at this CF. > > > I'm looking for a function that will allow me round the min from a > > now() function to the nearest 15. > > > So for example if it's 9:31 I would like it to return 30 > > > i've got TimeID set as a string: > > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) > > > which is working fine. and using mid or right am able to get the min > > separated, but the rounding functions seem to just round to whole > > numbers. > > I'd be fine with a floor or ceiling command too, so that 9:31 would > > return either 30 or 45. > > I'm using a numericupdown to get the user of the form to input time in > > increments of 15min. > > > And I guess since I'm on the topic is there anyway to make a > > NumericUpDown control flip? > > Using my original example. if I'm at 45 and press up I'd like it to > > revert back to 00. > > > thanks in advance |
|
|
|
#5 |
|
Guest
Posts: n/a
|
*Any* time you're getting a time, from anywhere, that is off by a number of
hours, immediately think "time zone". Whenever the offset is exactly one hour, think "daylight saving time". You haven't told us what device we're talking about, when you're making this call, etc., so it's a little hard to come up with a specific diagnosis. Since the parts of the US that do it are on DST right now, a first guess might be that either a) the PC to which you are syncing is not set for automatic DST adjustments or b) the device isn't. So, to go further, you'll have to tell us what time zone is set on the PC to which you are syncing, what time zone is set on the device, what OS the device is running, etc. You should also tell us *anything* that you are doing that might affect the current local time, the time zone, etc. Paul T. "Mark" <reeldeal81@gmail.com> wrote in message news:73c75d37-ddaf-4d81-966a-46b6d8b20e2d@d1g2000hsg.googlegroups.com... > Any idea why my now() statement is returning a time an hour in > advance? > my windows time is correct, is their a regional setting with vs.net > that could be out of whack? > > On Apr 17, 10:14 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT > no instrument no spam DOT com> wrote: >> Just do it yourself. Note that your rounding scheme doesn't round to the >> nearest, but it's very easy to handle that: >> >> ----- >> >> // Get the data from the text box. This is entered as a minutes value, >> more >> or less like >> >> // what you'd see from the DateTime.Now. >> >> Int32 min = Int32.Parse(textBox1.Text); >> >> // Round the minutes to the nearest 15. I get the number of 15 minute >> increments near >> >> // the minutes value here. One, the nearest 15 minute increment below >> and >> the other >> >> // above. >> >> Int32 inc = min / 15; >> >> Int32 inc1 = inc + 1; >> >> Int32 nearest; >> >> Int32 extrahour = 0; >> >> // Select the right increment. >> >> if (min - inc * 15 < inc1 * 15 - min) >> >> { >> >> nearest = inc * 15; >> >> } >> >> else >> >> { >> >> nearest = inc1 * 15; >> >> } >> >> // Now, you have to handle the case where the minutes are 60, since that >> doesn't make >> >> // sense >> >> if (nearest == 60) >> >> { >> >> nearest = 0; >> >> extrahour = 1; >> >> } >> >> // Show the minutes number and the extra hour that you need to add to >> your >> time (note that >> >> // this may also cause a wrap to the day, etc., so you have to handle >> that, >> too, to really have >> >> // a solution. >> >> label1.Text = nearest.ToString(); >> >> label2.Text = extrahour.ToString(); >> >> ----- >> >> Paul T. >> >> "Mark" <reeldea...@gmail.com> wrote in message >> >> news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... >> >> > Sorry, a bit new at this CF. >> >> > I'm looking for a function that will allow me round the min from a >> > now() function to the nearest 15. >> >> > So for example if it's 9:31 I would like it to return 30 >> >> > i've got TimeID set as a string: >> > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) >> >> > which is working fine. and using mid or right am able to get the min >> > separated, but the rounding functions seem to just round to whole >> > numbers. >> > I'd be fine with a floor or ceiling command too, so that 9:31 would >> > return either 30 or 45. >> > I'm using a numericupdown to get the user of the form to input time in >> > increments of 15min. >> >> > And I guess since I'm on the topic is there anyway to make a >> > NumericUpDown control flip? >> > Using my original example. if I'm at 45 and press up I'd like it to >> > revert back to 00. >> >> > thanks in advance > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Sorry. I'm using vs.net 2008's built in Mobile 6.0 emulator at this
point. My Windows time is set to Mountain Time (GMT-7) with automatically adjust dst clicked. It's odd in that i'm not doing anything besides running now() and it returns everything correct except the time is an hour in the future. i had forgotten about the fact dst had been slightly moved ahead this year. I thought the real dst had come and gone as well? To add to the confusion, I just opened the emulator because I realized the time is given at the top and that time is correct! Windows time = correct emulator time = correct now() = off by an hour. i'm puzzled. On Apr 17, 1:46 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com> wrote: > *Any* time you're getting a time, from anywhere, that is off by a number of > hours, immediately think "time zone". Whenever the offset is exactly one > hour, think "daylight saving time". You haven't told us what device we're > talking about, when you're making this call, etc., so it's a little hard to > come up with a specific diagnosis. Since the parts of the US that do it are > on DST right now, a first guess might be that either a) the PC to which you > are syncing is not set for automatic DST adjustments or b) the device isn't. > So, to go further, you'll have to tell us what time zone is set on the PC to > which you are syncing, what time zone is set on the device, what OS the > device is running, etc. You should also tell us *anything* that you are > doing that might affect the current local time, the time zone, etc. > > Paul T. > > "Mark" <reeldea...@gmail.com> wrote in message > > news:73c75d37-ddaf-4d81-966a-46b6d8b20e2d@d1g2000hsg.googlegroups.com... > > > Any idea why my now() statement is returning a time an hour in > > advance? > > my windows time is correct, is their a regional setting with vs.net > > that could be out of whack? > > > On Apr 17, 10:14 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT > > no instrument no spam DOT com> wrote: > >> Just do it yourself. Note that your rounding scheme doesn't round to the > >> nearest, but it's very easy to handle that: > > >> ----- > > >> // Get the data from the text box. This is entered as a minutes value, > >> more > >> or less like > > >> // what you'd see from the DateTime.Now. > > >> Int32 min = Int32.Parse(textBox1.Text); > > >> // Round the minutes to the nearest 15. I get the number of 15 minute > >> increments near > > >> // the minutes value here. One, the nearest 15 minute increment below > >> and > >> the other > > >> // above. > > >> Int32 inc = min / 15; > > >> Int32 inc1 = inc + 1; > > >> Int32 nearest; > > >> Int32 extrahour = 0; > > >> // Select the right increment. > > >> if (min - inc * 15 < inc1 * 15 - min) > > >> { > > >> nearest = inc * 15; > > >> } > > >> else > > >> { > > >> nearest = inc1 * 15; > > >> } > > >> // Now, you have to handle the case where the minutes are 60, since that > >> doesn't make > > >> // sense > > >> if (nearest == 60) > > >> { > > >> nearest = 0; > > >> extrahour = 1; > > >> } > > >> // Show the minutes number and the extra hour that you need to add to > >> your > >> time (note that > > >> // this may also cause a wrap to the day, etc., so you have to handle > >> that, > >> too, to really have > > >> // a solution. > > >> label1.Text = nearest.ToString(); > > >> label2.Text = extrahour.ToString(); > > >> ----- > > >> Paul T. > > >> "Mark" <reeldea...@gmail.com> wrote in message > > >>news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... > > >> > Sorry, a bit new at this CF. > > >> > I'm looking for a function that will allow me round the min from a > >> > now() function to the nearest 15. > > >> > So for example if it's 9:31 I would like it to return 30 > > >> > i've got TimeID set as a string: > >> > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) > > >> > which is working fine. and using mid or right am able to get the min > >> > separated, but the rounding functions seem to just round to whole > >> > numbers. > >> > I'd be fine with a floor or ceiling command too, so that 9:31 would > >> > return either 30 or 45. > >> > I'm using a numericupdown to get the user of the form to input time in > >> > increments of 15min. > > >> > And I guess since I'm on the topic is there anyway to make a > >> > NumericUpDown control flip? > >> > Using my original example. if I'm at 45 and press up I'd like it to > >> > revert back to 00. > > >> > thanks in advance |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Double-check the version of the framework (we want the latest). The .NET
CF, unfortunately, does a bunch of stuff that I think is silly behind the scenes with respect to dates and times. If it just used calls to the OS, each time you make a corresponding call to the framework function, there would be no problems. The most-common problem is that, when you change the date/time/timezone after you start your application, you're stuck, as it only reads the current time zone information on startup. This could also be a problem in your case. Paul T. "Mark" <reeldeal81@gmail.com> wrote in message news:c5ebd7e2-f139-460d-bf31-161794dd5d32@l64g2000hse.googlegroups.com... > Sorry. I'm using vs.net 2008's built in Mobile 6.0 emulator at this > point. > My Windows time is set to Mountain Time (GMT-7) with automatically > adjust dst clicked. > > It's odd in that i'm not doing anything besides running now() and it > returns everything correct except the time is an hour in the future. > i had forgotten about the fact dst had been slightly moved ahead this > year. I thought the real dst had come and gone as well? > > To add to the confusion, I just opened the emulator because I realized > the time is given at the top and that time is correct! > > Windows time = correct > emulator time = correct > now() = off by an hour. > > i'm puzzled. > > On Apr 17, 1:46 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT > no instrument no spam DOT com> wrote: >> *Any* time you're getting a time, from anywhere, that is off by a number >> of >> hours, immediately think "time zone". Whenever the offset is exactly one >> hour, think "daylight saving time". You haven't told us what device >> we're >> talking about, when you're making this call, etc., so it's a little hard >> to >> come up with a specific diagnosis. Since the parts of the US that do it >> are >> on DST right now, a first guess might be that either a) the PC to which >> you >> are syncing is not set for automatic DST adjustments or b) the device >> isn't. >> So, to go further, you'll have to tell us what time zone is set on the PC >> to >> which you are syncing, what time zone is set on the device, what OS the >> device is running, etc. You should also tell us *anything* that you are >> doing that might affect the current local time, the time zone, etc. >> >> Paul T. >> >> "Mark" <reeldea...@gmail.com> wrote in message >> >> news:73c75d37-ddaf-4d81-966a-46b6d8b20e2d@d1g2000hsg.googlegroups.com... >> >> > Any idea why my now() statement is returning a time an hour in >> > advance? >> > my windows time is correct, is their a regional setting with vs.net >> > that could be out of whack? >> >> > On Apr 17, 10:14 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT >> > no instrument no spam DOT com> wrote: >> >> Just do it yourself. Note that your rounding scheme doesn't round to >> >> the >> >> nearest, but it's very easy to handle that: >> >> >> ----- >> >> >> // Get the data from the text box. This is entered as a minutes >> >> value, >> >> more >> >> or less like >> >> >> // what you'd see from the DateTime.Now. >> >> >> Int32 min = Int32.Parse(textBox1.Text); >> >> >> // Round the minutes to the nearest 15. I get the number of 15 minute >> >> increments near >> >> >> // the minutes value here. One, the nearest 15 minute increment below >> >> and >> >> the other >> >> >> // above. >> >> >> Int32 inc = min / 15; >> >> >> Int32 inc1 = inc + 1; >> >> >> Int32 nearest; >> >> >> Int32 extrahour = 0; >> >> >> // Select the right increment. >> >> >> if (min - inc * 15 < inc1 * 15 - min) >> >> >> { >> >> >> nearest = inc * 15; >> >> >> } >> >> >> else >> >> >> { >> >> >> nearest = inc1 * 15; >> >> >> } >> >> >> // Now, you have to handle the case where the minutes are 60, since >> >> that >> >> doesn't make >> >> >> // sense >> >> >> if (nearest == 60) >> >> >> { >> >> >> nearest = 0; >> >> >> extrahour = 1; >> >> >> } >> >> >> // Show the minutes number and the extra hour that you need to add to >> >> your >> >> time (note that >> >> >> // this may also cause a wrap to the day, etc., so you have to handle >> >> that, >> >> too, to really have >> >> >> // a solution. >> >> >> label1.Text = nearest.ToString(); >> >> >> label2.Text = extrahour.ToString(); >> >> >> ----- >> >> >> Paul T. >> >> >> "Mark" <reeldea...@gmail.com> wrote in message >> >> >>news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... >> >> >> > Sorry, a bit new at this CF. >> >> >> > I'm looking for a function that will allow me round the min from a >> >> > now() function to the nearest 15. >> >> >> > So for example if it's 9:31 I would like it to return 30 >> >> >> > i've got TimeID set as a string: >> >> > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) >> >> >> > which is working fine. and using mid or right am able to get the min >> >> > separated, but the rounding functions seem to just round to whole >> >> > numbers. >> >> > I'd be fine with a floor or ceiling command too, so that 9:31 would >> >> > return either 30 or 45. >> >> > I'm using a numericupdown to get the user of the form to input time >> >> > in >> >> > increments of 15min. >> >> >> > And I guess since I'm on the topic is there anyway to make a >> >> > NumericUpDown control flip? >> >> > Using my original example. if I'm at 45 and press up I'd like it to >> >> > revert back to 00. >> >> >> > thanks in advance > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Sorry if this is a double post. i was pretty sure i replied.
It's definitely a DST error. Setting my date to Dec 18 2008 makes the now() statement time correct. So somewhere along the line one of my devices thinks we're out of DST. I'm running VS.Net 2008 on Windows XP. The time zone in xp is set to MST (-7) and adjust for DST is checked. I'm using the windows mobile 6.0 emulator within visual studio. The time at the top corner of my emulator is correct. Very peculiar, definitely related to DST. I know we switched early this year, but I'm pretty sure the normal day it comes into affect has occured as well. On Apr 17, 1:46 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com> wrote: > *Any* time you're getting a time, from anywhere, that is off by a number of > hours, immediately think "time zone". Whenever the offset is exactly one > hour, think "daylight saving time". You haven't told us what device we're > talking about, when you're making this call, etc., so it's a little hard to > come up with a specific diagnosis. Since the parts of the US that do it are > on DST right now, a first guess might be that either a) the PC to which you > are syncing is not set for automatic DST adjustments or b) the device isn't. > So, to go further, you'll have to tell us what time zone is set on the PC to > which you are syncing, what time zone is set on the device, what OS the > device is running, etc. You should also tell us *anything* that you are > doing that might affect the current local time, the time zone, etc. > > Paul T. > > "Mark" <reeldea...@gmail.com> wrote in message > > news:73c75d37-ddaf-4d81-966a-46b6d8b20e2d@d1g2000hsg.googlegroups.com... > > > Any idea why my now() statement is returning a time an hour in > > advance? > > my windows time is correct, is their a regional setting with vs.net > > that could be out of whack? > > > On Apr 17, 10:14 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT > > no instrument no spam DOT com> wrote: > >> Just do it yourself. Note that your rounding scheme doesn't round to the > >> nearest, but it's very easy to handle that: > > >> ----- > > >> // Get the data from the text box. This is entered as a minutes value, > >> more > >> or less like > > >> // what you'd see from the DateTime.Now. > > >> Int32 min = Int32.Parse(textBox1.Text); > > >> // Round the minutes to the nearest 15. I get the number of 15 minute > >> increments near > > >> // the minutes value here. One, the nearest 15 minute increment below > >> and > >> the other > > >> // above. > > >> Int32 inc = min / 15; > > >> Int32 inc1 = inc + 1; > > >> Int32 nearest; > > >> Int32 extrahour = 0; > > >> // Select the right increment. > > >> if (min - inc * 15 < inc1 * 15 - min) > > >> { > > >> nearest = inc * 15; > > >> } > > >> else > > >> { > > >> nearest = inc1 * 15; > > >> } > > >> // Now, you have to handle the case where the minutes are 60, since that > >> doesn't make > > >> // sense > > >> if (nearest == 60) > > >> { > > >> nearest = 0; > > >> extrahour = 1; > > >> } > > >> // Show the minutes number and the extra hour that you need to add to > >> your > >> time (note that > > >> // this may also cause a wrap to the day, etc., so you have to handle > >> that, > >> too, to really have > > >> // a solution. > > >> label1.Text = nearest.ToString(); > > >> label2.Text = extrahour.ToString(); > > >> ----- > > >> Paul T. > > >> "Mark" <reeldea...@gmail.com> wrote in message > > >>news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... > > >> > Sorry, a bit new at this CF. > > >> > I'm looking for a function that will allow me round the min from a > >> > now() function to the nearest 15. > > >> > So for example if it's 9:31 I would like it to return 30 > > >> > i've got TimeID set as a string: > >> > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) > > >> > which is working fine. and using mid or right am able to get the min > >> > separated, but the rounding functions seem to just round to whole > >> > numbers. > >> > I'd be fine with a floor or ceiling command too, so that 9:31 would > >> > return either 30 or 45. > >> > I'm using a numericupdown to get the user of the form to input time in > >> > increments of 15min. > > >> > And I guess since I'm on the topic is there anyway to make a > >> > NumericUpDown control flip? > >> > Using my original example. if I'm at 45 and press up I'd like it to > >> > revert back to 00. > > >> > thanks in advance |
|
|
|
#9 |
|
Guest
Posts: n/a
|
There are OS updates that have to be applied to make everything work. If
you are automatically updating XP, I'm sure those have happened. It's the device, including the emulator, that I'm most-concerned was properly updated, because the updates have to be installed and I'm not convinced that automatic updates for WM did that. The Energy Policy Act of 2006 was the law in the stupid US that changed when Daylight Saving Time occurs. Instead of the second Sunday in April, it was changed to the last Sunday in March and, instead of the last Sunday in October, it was changed to the first Sunday in November. Idiots; just idiots. Everyone knows that it has no positive effect on energy consumption and costs hundreds of millions of dollars, Euros, and every other currency in software time. DST is stupid to begin with anyway, but let's change it around periodically, in case one plan isn't dumb enough. I love how I've had to become something of an expert on all this time zone stuff and I live in one of the few areas in the US smart enough to not use those idiot adjustments. I've looked through the text above for probably an hour and it's still probably not right, but... Paul T. "Mark" <reeldeal81@gmail.com> wrote in message news:3e2dfe2e-826c-4308-89ef-20c9bc57c7d3@c58g2000hsc.googlegroups.com... > Sorry if this is a double post. i was pretty sure i replied. > > It's definitely a DST error. > > Setting my date to Dec 18 2008 makes the now() statement time correct. > So somewhere along the line one of my devices thinks we're out of DST. > > I'm running VS.Net 2008 on Windows XP. The time zone in xp is set to > MST (-7) and adjust for DST is checked. > I'm using the windows mobile 6.0 emulator within visual studio. > > The time at the top corner of my emulator is correct. > > Very peculiar, definitely related to DST. I know we switched early > this year, but I'm pretty sure the normal day it comes into affect has > occured as well. > > > On Apr 17, 1:46 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT > no instrument no spam DOT com> wrote: >> *Any* time you're getting a time, from anywhere, that is off by a number >> of >> hours, immediately think "time zone". Whenever the offset is exactly one >> hour, think "daylight saving time". You haven't told us what device >> we're >> talking about, when you're making this call, etc., so it's a little hard >> to >> come up with a specific diagnosis. Since the parts of the US that do it >> are >> on DST right now, a first guess might be that either a) the PC to which >> you >> are syncing is not set for automatic DST adjustments or b) the device >> isn't. >> So, to go further, you'll have to tell us what time zone is set on the PC >> to >> which you are syncing, what time zone is set on the device, what OS the >> device is running, etc. You should also tell us *anything* that you are >> doing that might affect the current local time, the time zone, etc. >> >> Paul T. >> >> "Mark" <reeldea...@gmail.com> wrote in message >> >> news:73c75d37-ddaf-4d81-966a-46b6d8b20e2d@d1g2000hsg.googlegroups.com... >> >> > Any idea why my now() statement is returning a time an hour in >> > advance? >> > my windows time is correct, is their a regional setting with vs.net >> > that could be out of whack? >> >> > On Apr 17, 10:14 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT >> > no instrument no spam DOT com> wrote: >> >> Just do it yourself. Note that your rounding scheme doesn't round to >> >> the >> >> nearest, but it's very easy to handle that: >> >> >> ----- >> >> >> // Get the data from the text box. This is entered as a minutes >> >> value, >> >> more >> >> or less like >> >> >> // what you'd see from the DateTime.Now. >> >> >> Int32 min = Int32.Parse(textBox1.Text); >> >> >> // Round the minutes to the nearest 15. I get the number of 15 minute >> >> increments near >> >> >> // the minutes value here. One, the nearest 15 minute increment below >> >> and >> >> the other >> >> >> // above. >> >> >> Int32 inc = min / 15; >> >> >> Int32 inc1 = inc + 1; >> >> >> Int32 nearest; >> >> >> Int32 extrahour = 0; >> >> >> // Select the right increment. >> >> >> if (min - inc * 15 < inc1 * 15 - min) >> >> >> { >> >> >> nearest = inc * 15; >> >> >> } >> >> >> else >> >> >> { >> >> >> nearest = inc1 * 15; >> >> >> } >> >> >> // Now, you have to handle the case where the minutes are 60, since >> >> that >> >> doesn't make >> >> >> // sense >> >> >> if (nearest == 60) >> >> >> { >> >> >> nearest = 0; >> >> >> extrahour = 1; >> >> >> } >> >> >> // Show the minutes number and the extra hour that you need to add to >> >> your >> >> time (note that >> >> >> // this may also cause a wrap to the day, etc., so you have to handle >> >> that, >> >> too, to really have >> >> >> // a solution. >> >> >> label1.Text = nearest.ToString(); >> >> >> label2.Text = extrahour.ToString(); >> >> >> ----- >> >> >> Paul T. >> >> >> "Mark" <reeldea...@gmail.com> wrote in message >> >> >>news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... >> >> >> > Sorry, a bit new at this CF. >> >> >> > I'm looking for a function that will allow me round the min from a >> >> > now() function to the nearest 15. >> >> >> > So for example if it's 9:31 I would like it to return 30 >> >> >> > i've got TimeID set as a string: >> >> > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) >> >> >> > which is working fine. and using mid or right am able to get the min >> >> > separated, but the rounding functions seem to just round to whole >> >> > numbers. >> >> > I'd be fine with a floor or ceiling command too, so that 9:31 would >> >> > return either 30 or 45. >> >> > I'm using a numericupdown to get the user of the form to input time >> >> > in >> >> > increments of 15min. >> >> >> > And I guess since I'm on the topic is there anyway to make a >> >> > NumericUpDown control flip? >> >> > Using my original example. if I'm at 45 and press up I'd like it to >> >> > revert back to 00. >> >> >> > thanks in advance > |
|
|
|
#10 |
|
Guest
Posts: n/a
|
i'm using .net compact framework version 3.5
if that helps any? On Apr 18, 10:17 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com> wrote: > There are OS updates that have to be applied to make everything work. If > you are automatically updating XP, I'm sure those have happened. It's the > device, including the emulator, that I'm most-concerned was properly > updated, because the updates have to be installed and I'm not convinced that > automatic updates for WM did that. > > The Energy Policy Act of 2006 was the law in the stupid US that changed when > Daylight Saving Time occurs. Instead of the second Sunday in April, it was > changed to the last Sunday in March and, instead of the last Sunday in > October, it was changed to the first Sunday in November. Idiots; just > idiots. Everyone knows that it has no positive effect on energy consumption > and costs hundreds of millions of dollars, Euros, and every other currency > in software time. DST is stupid to begin with anyway, but let's change it > around periodically, in case one plan isn't dumb enough. > > I love how I've had to become something of an expert on all this time zone > stuff and I live in one of the few areas in the US smart enough to not use > those idiot adjustments. I've looked through the text above for probably an > hour and it's still probably not right, but... > > Paul T. > > "Mark" <reeldea...@gmail.com> wrote in message > > news:3e2dfe2e-826c-4308-89ef-20c9bc57c7d3@c58g2000hsc.googlegroups.com... > > > Sorry if this is a double post. i was pretty sure i replied. > > > It's definitely a DST error. > > > Setting my date to Dec 18 2008 makes the now() statement time correct. > > So somewhere along the line one of my devices thinks we're out of DST. > > > I'm running VS.Net 2008 on Windows XP. The time zone in xp is set to > > MST (-7) and adjust for DST is checked. > > I'm using the windows mobile 6.0 emulator within visual studio. > > > The time at the top corner of my emulator is correct. > > > Very peculiar, definitely related to DST. I know we switched early > > this year, but I'm pretty sure the normal day it comes into affect has > > occured as well. > > > On Apr 17, 1:46 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT > > no instrument no spam DOT com> wrote: > >> *Any* time you're getting a time, from anywhere, that is off by a number > >> of > >> hours, immediately think "time zone". Whenever the offset is exactly one > >> hour, think "daylight saving time". You haven't told us what device > >> we're > >> talking about, when you're making this call, etc., so it's a little hard > >> to > >> come up with a specific diagnosis. Since the parts of the US that do it > >> are > >> on DST right now, a first guess might be that either a) the PC to which > >> you > >> are syncing is not set for automatic DST adjustments or b) the device > >> isn't. > >> So, to go further, you'll have to tell us what time zone is set on the PC > >> to > >> which you are syncing, what time zone is set on the device, what OS the > >> device is running, etc. You should also tell us *anything* that you are > >> doing that might affect the current local time, the time zone, etc. > > >> Paul T. > > >> "Mark" <reeldea...@gmail.com> wrote in message > > >>news:73c75d37-ddaf-4d81-966a-46b6d8b20e2d@d1g2000hsg.googlegroups.com... > > >> > Any idea why my now() statement is returning a time an hour in > >> > advance? > >> > my windows time is correct, is their a regional setting with vs.net > >> > that could be out of whack? > > >> > On Apr 17, 10:14 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT > >> > no instrument no spam DOT com> wrote: > >> >> Just do it yourself. Note that your rounding scheme doesn't round to > >> >> the > >> >> nearest, but it's very easy to handle that: > > >> >> ----- > > >> >> // Get the data from the text box. This is entered as a minutes > >> >> value, > >> >> more > >> >> or less like > > >> >> // what you'd see from the DateTime.Now. > > >> >> Int32 min = Int32.Parse(textBox1.Text); > > >> >> // Round the minutes to the nearest 15. I get the number of 15 minute > >> >> increments near > > >> >> // the minutes value here. One, the nearest 15 minute increment below > >> >> and > >> >> the other > > >> >> // above. > > >> >> Int32 inc = min / 15; > > >> >> Int32 inc1 = inc + 1; > > >> >> Int32 nearest; > > >> >> Int32 extrahour = 0; > > >> >> // Select the right increment. > > >> >> if (min - inc * 15 < inc1 * 15 - min) > > >> >> { > > >> >> nearest = inc * 15; > > >> >> } > > >> >> else > > >> >> { > > >> >> nearest = inc1 * 15; > > >> >> } > > >> >> // Now, you have to handle the case where the minutes are 60, since > >> >> that > >> >> doesn't make > > >> >> // sense > > >> >> if (nearest == 60) > > >> >> { > > >> >> nearest = 0; > > >> >> extrahour = 1; > > >> >> } > > >> >> // Show the minutes number and the extra hour that you need to add to > >> >> your > >> >> time (note that > > >> >> // this may also cause a wrap to the day, etc., so you have to handle > >> >> that, > >> >> too, to really have > > >> >> // a solution. > > >> >> label1.Text = nearest.ToString(); > > >> >> label2.Text = extrahour.ToString(); > > >> >> ----- > > >> >> Paul T. > > >> >> "Mark" <reeldea...@gmail.com> wrote in message > > >> >>news:78c2e66e-577e-456c-884f-117d7636f7ee@p25g2000hsf.googlegroups.com... > > >> >> > Sorry, a bit new at this CF. > > >> >> > I'm looking for a function that will allow me round the min from a > >> >> > now() function to the nearest 15. > > >> >> > So for example if it's 9:31 I would like it to return 30 > > >> >> > i've got TimeID set as a string: > >> >> > TimeId = FormatDateTime(Now(), DateFormat.ShortTime) > > >> >> > which is working fine. and using mid or right am able to get the min > >> >> > separated, but the rounding functions seem to just round to whole > >> >> > numbers. > >> >> > I'd be fine with a floor or ceiling command too, so that 9:31 would > >> >> > return either 30 or 45. > >> >> > I'm using a numericupdown to get the user of the form to input time > >> >> > in > >> >> > increments of 15min. > > >> >> > And I guess since I'm on the topic is there anyway to make a > >> >> > NumericUpDown control flip? > >> >> > Using my original example. if I'm at 45 and press up I'd like it to > >> >> > revert back to 00. > > >> >> > thanks in advance |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

