summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/test1.c
blob: bb83ade2310dfb14f29f23a202efa2a2c7ace543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*============================================================================
**
** Source: test1.c
**
** Purpose: Tests that GetTimeZoneInformation gives reasonable values.
**
**
**==========================================================================*/


#include <palsuite.h>

int __cdecl main(int argc, char *argv[])
{
    TIME_ZONE_INFORMATION tzi;
    DWORD ret;

    if (PAL_Initialize(argc, argv))
    {
        return FAIL;
    }

    ret = GetTimeZoneInformation(&tzi);
    if (ret == TIME_ZONE_ID_UNKNOWN) 
    {        
        /* Occurs in time zones that do not use daylight savings time. */
        if (tzi.StandardBias != 0)
        {
            Fail("GetTimeZoneInformation() gave invalid data!\n"
                "Returned TIME_ZONE_ID_UNKNOWN but StandardBias != 0!\n");
        }
        if (tzi.DaylightBias != 0)
        {
            Fail("GetTimeZoneInformation() gave invalid data!\n"
                "Returned TIME_ZONE_ID_UNKNOWN but DaylightBias != 0!\n");
        }
    }    
    else if (ret == TIME_ZONE_ID_STANDARD)
    {
        if (tzi.StandardBias != 0)
        {
            Fail("GetTimeZoneInformation() gave invalid data!\n"
                "StandardBias is %d, should be 0!\n", tzi.StandardBias);
        }
    }
    else if (ret == TIME_ZONE_ID_DAYLIGHT)
    {
        if (tzi.DaylightBias != -60 && tzi.DaylightBias != 0)
        {
            Fail("GetTimeZoneInformation() gave invalid data!\n"
                "DaylightBias is %d, should be 0 or -60!\n", tzi.DaylightBias);
        }
    }
    else 
    {
        Fail("GetTimeZoneInformation() returned an invalid value!\n");
    }

    if (tzi.Bias % 30 != 0)
    {
        Fail("GetTimeZoneInformation() gave an invalid bias of %d!\n", 
            tzi.Bias);
    }

    PAL_Terminate();

    return PASS;
}