{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Location.Types.TimeZone
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Location.Types.TimeZone where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Information about a time zone. Includes the name of the time zone and
-- the offset from UTC in seconds.
--
-- /See:/ 'newTimeZone' smart constructor.
data TimeZone = TimeZone'
  { -- | The time zone\'s offset, in seconds, from UTC.
    TimeZone -> Maybe Int
offset :: Prelude.Maybe Prelude.Int,
    -- | The name of the time zone, following the
    -- <https://www.iana.org/time-zones IANA time zone standard>. For example,
    -- @America\/Los_Angeles@.
    TimeZone -> Text
name :: Prelude.Text
  }
  deriving (TimeZone -> TimeZone -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeZone -> TimeZone -> Bool
$c/= :: TimeZone -> TimeZone -> Bool
== :: TimeZone -> TimeZone -> Bool
$c== :: TimeZone -> TimeZone -> Bool
Prelude.Eq, ReadPrec [TimeZone]
ReadPrec TimeZone
Int -> ReadS TimeZone
ReadS [TimeZone]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeZone]
$creadListPrec :: ReadPrec [TimeZone]
readPrec :: ReadPrec TimeZone
$creadPrec :: ReadPrec TimeZone
readList :: ReadS [TimeZone]
$creadList :: ReadS [TimeZone]
readsPrec :: Int -> ReadS TimeZone
$creadsPrec :: Int -> ReadS TimeZone
Prelude.Read, Int -> TimeZone -> ShowS
[TimeZone] -> ShowS
TimeZone -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeZone] -> ShowS
$cshowList :: [TimeZone] -> ShowS
show :: TimeZone -> String
$cshow :: TimeZone -> String
showsPrec :: Int -> TimeZone -> ShowS
$cshowsPrec :: Int -> TimeZone -> ShowS
Prelude.Show, forall x. Rep TimeZone x -> TimeZone
forall x. TimeZone -> Rep TimeZone x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeZone x -> TimeZone
$cfrom :: forall x. TimeZone -> Rep TimeZone x
Prelude.Generic)

-- |
-- Create a value of 'TimeZone' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'offset', 'timeZone_offset' - The time zone\'s offset, in seconds, from UTC.
--
-- 'name', 'timeZone_name' - The name of the time zone, following the
-- <https://www.iana.org/time-zones IANA time zone standard>. For example,
-- @America\/Los_Angeles@.
newTimeZone ::
  -- | 'name'
  Prelude.Text ->
  TimeZone
newTimeZone :: Text -> TimeZone
newTimeZone Text
pName_ =
  TimeZone' {$sel:offset:TimeZone' :: Maybe Int
offset = forall a. Maybe a
Prelude.Nothing, $sel:name:TimeZone' :: Text
name = Text
pName_}

-- | The time zone\'s offset, in seconds, from UTC.
timeZone_offset :: Lens.Lens' TimeZone (Prelude.Maybe Prelude.Int)
timeZone_offset :: Lens' TimeZone (Maybe Int)
timeZone_offset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeZone' {Maybe Int
offset :: Maybe Int
$sel:offset:TimeZone' :: TimeZone -> Maybe Int
offset} -> Maybe Int
offset) (\s :: TimeZone
s@TimeZone' {} Maybe Int
a -> TimeZone
s {$sel:offset:TimeZone' :: Maybe Int
offset = Maybe Int
a} :: TimeZone)

-- | The name of the time zone, following the
-- <https://www.iana.org/time-zones IANA time zone standard>. For example,
-- @America\/Los_Angeles@.
timeZone_name :: Lens.Lens' TimeZone Prelude.Text
timeZone_name :: Lens' TimeZone Text
timeZone_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeZone' {Text
name :: Text
$sel:name:TimeZone' :: TimeZone -> Text
name} -> Text
name) (\s :: TimeZone
s@TimeZone' {} Text
a -> TimeZone
s {$sel:name:TimeZone' :: Text
name = Text
a} :: TimeZone)

instance Data.FromJSON TimeZone where
  parseJSON :: Value -> Parser TimeZone
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimeZone"
      ( \Object
x ->
          Maybe Int -> Text -> TimeZone
TimeZone'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Offset")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance Prelude.Hashable TimeZone where
  hashWithSalt :: Int -> TimeZone -> Int
hashWithSalt Int
_salt TimeZone' {Maybe Int
Text
name :: Text
offset :: Maybe Int
$sel:name:TimeZone' :: TimeZone -> Text
$sel:offset:TimeZone' :: TimeZone -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
offset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData TimeZone where
  rnf :: TimeZone -> ()
rnf TimeZone' {Maybe Int
Text
name :: Text
offset :: Maybe Int
$sel:name:TimeZone' :: TimeZone -> Text
$sel:offset:TimeZone' :: TimeZone -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
offset seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name