Best way to get the time zone

I'm looking for the current time zone of the user. In my view, there is a function that seems to be able to do as part of the Pim calendar. I have to ask permission to do seems like overkill when I just want to get the current time zone is not currently using the calendar functions.

http://developer.BlackBerry.com/native/reference/Cascades/bb__pim__calendar__calendarsettings.html#f...

Is there a better way to do it?

This can be quite difficult because there isn't anyway that I am aware of ask BB10 directly for the offset of UTC (GMT). The basic procedure is:

  • Get the current time with QDateTime::currentDateTime()
  • Make a copy with QDateTime::toUTC()
  • Force the date in UTC format.
  • The difference between the two dates and times now corresponds to the offset from UTC.

Something like this:

QDateTime dt1 = QDateTime::currentDateTime();
QDateTime dt2 = dt1.toUTC();
dt1.setTimeSpec(Qt::UTC);

int offset = dt2.secsTo(dt1);

After that it works offset will contain the offset from UTC in seconds, so divide by 3600 if you want hours.

UPDATE: For everyone it is the future that has understanding of the difficulties of reading what the hell happens in this code...

  • Line, you get just the date and time in a QDateTime. This will be the time in the local time zone. It doesn't have to be updated to do this, any date and time will be, but current is convenient.
  • Line two is a copy of the first date and time, but as one hour UTC. If, for example, if you are in Toronto to UTC - 5:00 and the current local time is 15:46, then T2D will be set at 20:46, the time in Greenwich, England, but the dates are in fact always the same, because we're local, and the other is UTC. For this reason, at this point by subtracting from each other will result in zero, because they are actually exactly the same date and time.
  • Third line says to t1d" I know you think you're time local 15:46, but you're actually 15:46 UTC. " T1d believes that without a doubt. Now the two dates are actually different and separated by the local offset to the hour UTC.

Hope this makes things clearer because the reason that this code works may not be obvious.

Tags: BlackBerry Developers

Similar Questions

  • do not get the time zone on the basis of the city.

    Hello guys, I'm getting the time zone based on the region,

    As America/LosAngelies(-8);

    But I want that on the basis of the town as London(-7) and Adeleid (+ 5);

    How can I achieve this. Help, please.

    Resolved.

    Use the method of getDisplayNames (0). For time zones the device all.

  • Flex Mobile Application and get the time zone

    Hello

    I need to know the time in a Mobile application in order to perform some calculations.

    The problem is that I need to know the time from the GMT.

    Is there anyway to zone set by the user to detect or somehow get the time?

    not tried but it's any help

    Date

    timezoneOffset : number

    [read-only] The difference, in minutes, between the time universal (UTC) and the local time of the computer.
  • Best way to get the content of the 1 page in a lot?

    Hi everyone - I just wanted to check with experts on the best way to get information from 1 html page.  For example, I have a page that shows every 1 '' Ribbons that we have in stock to be used on sandals, belts, bags, etc. dog collars;  (http://elizab.com/eb-1-inchribbons.html) I can do an iframe to pull this html page 1 to all others?  What is the best way to do it?

    Basically I just have to update only one page html (tapes 1 ") and then it is good on all other pages, instead of having me to go through and to update every page that uses ribbons 1" :-)

    I'm not sure what is always taken in charge and what is not recommended on this!

    Thank you-

    Use an SSI. Server Side includes. It's better than an iframe. Google for server-side includes.

    Usually, I use php for inclusions on server side, but your server must support php. If not, you can use .shtml server-side includes.

    You need only to update and download only one file when you want to make changes. So on what page/s you have included the SSI these pages updated as well.

    Although I am a little confused because your field of design takes a page in its entirety. How do you intend to include all of the information on other pages without doubt that contain other information as well?

    I guess that if you only have a small area in which to display all the different designs on your pages, then an iframe is probably the best solution for your because you can define its dimensions.

    Personally I would get really "upset" if I have to keep scrolling left and right and top and bottom, then maybe if you go the route iframe you can arrange at least all the vertical stripes so we don't have to scroll up and down or break designs down into smaller categories to its more manageable for the end user.

  • What is the best way to get the minimum or maximum of a table of numbers value?

    Let's say I have a table of numbers: [2,3,3,4,2,2,5,6,7,2]

    What is the best way to find the minimum or maximum value in the table?

    Now, just get the maximum, I'm a loop in the table and reset a variable to the value if it is greater than the existing value:

    What I ended up doing was sorting table (descending to MAX) upward for MIN and then grabbing the first element of the array. Works like a charm in very few lines of code.

    Thank you.

  • Best way to get the EBITDA, calculated or hierarchy?

    I have a client who has a hierarchy of multi-level natural account that includes the core accounts and leads all the way to its Net income. However, they would like an account called EBITDA to be able to reference using smartview rules.

    What do you recommend is the best way to do this? I was looking for to use the natural hierarchy counts, but all their groups the way they want them already, I need to be able to have some sort of alternative account hierarchy (similar to a hierarchy of entities replacement), but I don't know if this is possible.

    I could use an account calculated, but it would be nice to be able to get the EBE without having to run a consolidation every time a change for companies of basic number, but it might be the easiest way to do it.

    All advice is appreciated!

    Yes, quite possible to have a flow of the basic account upwards in any number of parents. You only download the account once. You would be reconsolidate as many times as necessary.

    Hierarchy1
       - Acct_A
       - Acct_B
    
    Hierarchy 2
       - Acct_A
       - Acct_C
    

    You load Acct_A once and consolidate the hierarchy 1 and 2 to get the totals you want. If you want to slightly reduce the manual steps, you could give the two hierarchies shared parent so you can kick off a consolidation at the top.

    Hierarchy3
       -Hierarchy1
          - Acct_A
          - Acct_B
       -Hierarchy 2
          - Acct_A
          - Acct_C
    
  • Get the time zone when select the region fron DropDownList

    Hello guys,.
    I am applying in which,
    I get all the zone in an ObjectChoiceField list.
    Now, when I select one of them,
    I want to get this time
    As I put the zone in the operative Asia/Kolkata.
    Now in the My Code.
    I select the 'America/Denver' of ObjectChoiceField.
    Now, I want time zone "America/Denver '.

    How can I do that. I'm frustrated.

    I have less time.

    Please someone help me.

    Resolved. Thank you all guys.

  • BlackBerry Smartphones best way to get the best picture, the phone is off?

    I think it's true that when we send a jpeg image which was obtained using the camera of the phone it is compressed... to a certain extent.

    What is the best way to dload an image uncompressed computer desktop or such so that we can get the higher resolution image?

    Hey copperbeech,.

    You can also use the mass storage Mode to browse your BlackBerry Media Card of your computer to find the image and copy it to a folder on your PC.

    Thank you

  • Best way to track the time of calculation of planning

    Hello

    Our management has asked us to provide monthly reports of the time of calculations in our main application of planning.

    We have identified one or two global level calculations we want to follow.   We run these calcs about 6 times a day on average.

    But it is almost impossible to sort through the massive application log (when presentations are completed) and filter it down (we tried, but newspaper is very difficult to work with).

    Has anyone developed a simple method (automatic) for the monitoring of the amount of time it takes for a calculation specific to planning?   We use calc Manager by the way to expand our rules and rulesets.   Ideally, we could get some kind of automated report which showed us the cases when the specific rule / ruleset ran and the duration of each instance.

    Thank you
    Mark

    Hi Mark,

    If these are calc manager rule, you should have all the necessary details in the HSP_JOB_STATUS table. You may be able to get this information from a simple query on this table. However, this information is also available in your planning application via Tools-> "Work Console" option, you will not see the time of calculation. It shows only the start and end time.

    Kind regards

    Sunil

  • best way to get the o/p

    Jin
    I get same table 3 times for the desired output. a better way to reach the o/p

    begin_date resresents milestine_id 1670
    milestine_id 1690 resresents end_date

    begindate and end_date are not present for 672798, they should be shown as null. so, I'm using outerjoin
    WITH table1 AS
         (SELECT '672797' tin, '1670' milestone_id,
                 TO_DATE ('07/1/2009', 'mm/dd/yyyy') milestone_date
            FROM DUAL
          UNION ALL
          SELECT '672797' tin, '1690' milestone_id,
                 TO_DATE ('07/20/2009', 'mm/dd/yyyy') milestone_date
            FROM DUAL
          UNION ALL
          SELECT '672798' tin, '100' milestone_id, NULL AS milestone_date
            FROM DUAL
          UNION ALL
          SELECT '672798' tin, '200' milestone_id, NULL AS milestone_date
            FROM DUAL)
    SELECT  c.tin , a.milestone_date as begin_date ,  b.milestone_date as end_date
      FROM table1 a, table1 b , table1 c
      where c.tin = a.tin(+)
      and c.tin = b.tin(+)
      and a.milestone_id(+) = 1670
      and b.milestone_id(+) = 1690
      group by c.tin , a.milestone_date  ,  b.milestone_date;
    o/p required

    begin_date Tin end_date
    672797 7/1/2009 7/20/2009
    672798

    Published by: DeepakDevarapalli on October 23, 2009 11:17

    I hope I understood the right of prescription. I did use a swivel technique to retrieve results from the same table.

    SQL> WITH table1 AS
      2       (SELECT '672797' tin, '1670' milestone_id,
      3               TO_DATE ('07/1/2009', 'mm/dd/yyyy') milestone_date
      4          FROM DUAL
      5        UNION ALL
      6        SELECT '672797' tin, '1690' milestone_id,
      7               TO_DATE ('07/20/2009', 'mm/dd/yyyy') milestone_date
      8          FROM DUAL
      9        UNION ALL
     10        SELECT '672798' tin, '100' milestone_id, NULL AS milestone_date
     11          FROM DUAL
     12        UNION ALL
     13        SELECT '672798' tin, '200' milestone_id, NULL AS milestone_date
     14          FROM DUAL)
     15  SELECT  TIN
     16  ,       MAX(DECODE(MILESTONE_ID,1670,MILESTONE_DATE))        AS BEGIN_DATE
     17  ,       MAX(DECODE(MILESTONE_ID,1690,MILESTONE_DATE))        AS END_DATE
     18  FROM    table1
     19  GROUP BY TIN
     20  ORDER BY TIN
     21  /
    
    TIN    BEGIN_DATE          END_DATE
    ------ ------------------- -------------------
    672797 07/01/2009 00:00:00 07/20/2009 00:00:00
    672798
    
  • The search for the best way to get the data

    Sorry for my bad English.

    * 1. Definition * the task
    I have the table "tab01":

    ID; EVENT_DATE; Item1; Item2... itemN
    ______________________________
    1; 01.01.2009; A; null; ... null
    2; 02.01.2009; B; 1; ... null
    3; 03.01.2009; null; 2; ... 3
    4; 04.01.2009; null; null; ... 4

    I need to get the last non-null column values (item1... itemN) on the date chosen (result line).
    For example, the result on 03.01.2009 will be:

    EVENT_DATE; Item1; Item2... itemN
    ______________________________
    03.01.2009; B; 2 ... 3

    * 2.  My decision *.
    My decision (it works, but I think that's not good) was:
    1. create the package with
    (a) methods to get and set the date,
    (b) the functions which are the values required;
    2. create the view based on the functions of the package.

    create or replace package is P_STATE
    -The public variable declarations
    Trunc (sysdate) default date StateDate;

    -Declarations of function and public procedure
    procedure SetStateDate (date date);
    function GetStateDate return date;

    function GetItem1 return tab01.item1%type;
    ...
    function GetItemN return tab01.itemN%type;

    end P_STATE;

    create or replace package body is P_STATE

    procedure SetStateDate (date date) is
    Start
    StateDate: = Al;
    end;

    function GetStateDate return date is
    Start
    Return StateDate;
    end;

    function tab01.item1%type return GetItem1 is
    Result tab01.item1%type;
    cursor c1 is select item1 tab01
    where item1 is not null and
    EVENT_DATE < = StateDate
    event_date desc order.
    Start
    Open c1;
    Fetch c1 into result.
    Close c1;
    Return (result);
    end;

    ...

    function GetItemN return tab01.itemN%type is
    ...
    end P_STATE;

    create or replace view v_tab01
    (date_on, item1,... itemN)
    in select
    p_state. GetStateDate,
    p_state. GetItem1,
    ...
    p_state. GetItemN
    Double;

    Can you help me to find the best way?

    You might if it were a feature in pipeline. Check it out here: [http://www.akadia.com/services/ora_pipe_functions.html]

  • Pavilion 500-281: where to install a SSD and the best way to get the operating system on it

    I have a Pavilion nine 500-281 with Win 7. I bouight a SSD 128 GB to load the operating system on it.  Where can I get inside the chassis? It seem not to be berries of classical records. It came with an adapter with the screw plate, but it's not obvious where I was able to ride the thing!

    In addition, can I just run a restore to get the OS on the SSD drive, once I have installed?  I received instructions with the SSD for ADATA software copy an image of the disk, but all I want is the operating system.  I'm dying to start using my new computer, but I think I want to get the reader installed first before you make any changes that he.

    Hello

    Review the #8 message in this thread.  Not all models of the 500 - 2xx Pavilion are provisioned for the SSD in the location as shown.  In the indicated installation, an adapter plate was not necessary.

    Most SSD manufacturers have free software migration.  I suggest that you image the entire HD, all partitions even hidden partitions.  Some of the more recent migration software will allow you to exclude your data records.

  • What is the best way to reduce the time in a WCC 11.1.1.8 to 11.1.1.9 update?

    I have a requirement to get a zero down time upgrade from the COE 11.1.1.8 to 11.1.1.9 in an environment with a cluster of 6 knots. From what I see in the documentation, it can be very difficult; If someone who has done this upgrade has all the lessons learned on how to optimize in order to minimize the downtime that I would really appreciate it.

    If you can afford to create a second copy of your production environment (both compute power and storage), you could be close to no interruption of service.

    (1) with your DR procedures create the second copy of your environment, and restore your data it

    (2) use the process that amey g called to upgrade the second environment

    (3) your new test environment (you'll almost have the same data, only missing will be those created/updated day after taking backup in #1).

    (4) use the archiver utility to export/import the missing data to the new system

    (5) to redirect users to the new system

    It's only the steps #4 and #5 which cannot be done at the same time, and only #4 can take some significant time. If you have a large amount of data the archiver would have to be synchronized, you can consider other tools such as GoldenGate, rather than of the archive.

  • Adding videos to a site. the best way to get the best result (for the customer)

    Hi all


    Here's a new question, I asked myself.


    I have to add some videos to the website of the client. Short. About 15-30 MB each.

    So we will not have to wait forever for them to start playing, it is best to:


    1. Load them all with the rest of the web site in two different formats, so they will play on most of the browsers, then use a video widget in Muse.

    Of course, creating a massive gigantic site.


    2. Create a channel private on Utube, download all here paste them the youtube ID in a youtube Widget in Muse?


    3. Another way?


    Also is there a scrolling effect method so let's say the video is at the bottom of the page and it will only start when through us it.

    Kind regards

    M

    YouTube or Vimeo.

    These 3rd party services are free, they have a fast hosting, they work on all devices and browsers, and the customer can manage/edit video easily.

  • What is the best way to get the print screens clear?

    Hello

    I didn't know where else to post this so I thought I would try here.

    I have various programs that I sell on ebay and I need clear photos of my different screens on ebay.    Can someone tell me how to get clear jpgs from my shutters?

    Thank you

    Phil

    Could you explain the problems you encounter. A screen
    shot should look exactly like the screen you copied.

    FWIW... the tool captures of Vista might be worth a try:

    Windows Vista-
    Activate the Vista Snipping Tool
    http://www.PCWorld.com/article/137099/activate_vistas_snipping_tool.html

    Use capture tool to capture screenshots
    http://Windows.Microsoft.com/en-us/Windows-Vista/use-Snipping-Tool-to-capture-screen-shots

    Vista tutorial - How to use the tool captures of Vista
    http://www.Vistax64.com/tutorials/148532-how-use-Snipping-Tool-Vista.html

Maybe you are looking for

  • Cannot connect iphone 5 itunes store

    Just the last OS installed yesterday evening. Now cannot connect to itunes store. Thin WiFi, date time very well, everything else works fine... not a subscriber of apple's music I get the link in the app store for 'visit the itunes store', but nothin

  • lack of sub vi

    Hello. I am looking for the following under vi. I use a channel 16 DAQ card to read analog voltages in Labview. The main VI I use was downloaded from the examples NOR in 2004. The PC I used 04 was thrown at some point. I now use the same main VI on a

  • LaserJet4 more: Windows 10 driver for HP printer

    My printer LaserJet4 Plus worked fine on Windows 8. However, when I upgraded to Windows 10, the printer is not recognized. What can I do now?

  • Photosmart C309a don't scan

    My C309a don't scan: -When I press the button on the printer, it is said there is a problem of scan and told me to "try to start the scan of the computer, refer to the documentation for more details" -When I open the HP solution on the Office Center,

  • I am able to scan from the scanner and printer, but can't seem to scan onto computor

    I am able to scan from the scanner and printer, but can't seem to scan on computor, what I have to do.