Skip to content

Commit

Permalink
Docs for new sap.common.TimeZone
Browse files Browse the repository at this point in the history
  • Loading branch information
chgeo committed Feb 15, 2024
1 parent 2869a35 commit c1771fb
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions cds/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ CDS ships with a prebuilt model *`@sap/cds/common`* that provides common types a
[ISO 3166-3]: https://en.wikipedia.org/wiki/ISO_3166-3
[ISO 4217]: https://en.wikipedia.org/wiki/ISO_4217
[ISO/IEC 15897]: https://en.wikipedia.org/wiki/ISO/IEC_15897
[tzdata]: https://en.wikipedia.org/wiki/Tz_database
[localized data]: ../guides/localized-data
[temporal data]: ../guides/temporal-data

Expand Down Expand Up @@ -131,7 +132,7 @@ _@sap/cds/common_ provides predefined easy-to-use types for _Countries_, _Curren
### Type `Country`
[`Country`]: #country

The reuse type `Country` is defined in _@sap/cds/common_ as a simple managed [Association](cdl#associations) to the [code list](#code-lists) for countries as follows:
The reuse type `Country` is defined in _@sap/cds/common_ as a simple managed [Association](cdl#associations) to the [code list](#code-lists) for [countries](#entity-countries) as follows:

```cds
type Country : Association to sap.common.Countries;
Expand Down Expand Up @@ -165,6 +166,8 @@ CREATE TABLE Addresses (

### Type `Currency`

The type for an association to [Currencies](#entity-currencies).

```cds
type Currency : Association to sap.common.Currencies;
```
Expand All @@ -173,12 +176,24 @@ type Currency : Association to sap.common.Currencies;

### Type `Language`

The type for an association to [Languages](#entity-languages).

```cds
type Language : Association to sap.common.Languages;
```

[It's the same as for `Country`.](#type-country){ .learn-more}

### Type `TimeZone`

The type for an association to [TimeZones](#entity-timezones).

```cds
type TimeZone : Association to sap.common.TimeZones;
```

[It's the same as for `Country`.](#type-country){ .learn-more}

## Common Code Lists { #code-lists}

As seen in the previous section, the reuse types `Country`, `Currency`, and `Language` are defined as associations to respective code list entities. They act as code list tables for respective elements in your domain model.
Expand Down Expand Up @@ -237,6 +252,16 @@ entity sap.common.Languages : CodeList {
```
[Learn more on **normalized locales**.](../guides/i18n#normalized-locales){ .learn-more}

### Entity `TimeZones`

The code list entity for time zones is meant to be used with _Area/Location_ names as defined in the [IANA time zone database][tzdata] as primary keys. Examples are `America/Argentina/Buenos_Aires`, `Europe/Berlin`, or `Etc/UTC`.

```cds
entity sap.common.TimeZones : CodeList {
key code : String(100); //> for example, Europe/Berlin
}
```


### SQL Persistence

Expand Down Expand Up @@ -428,7 +453,7 @@ You can use Excel or similar tools to maintain these files. For example, the fol

### Using Prebuilt Content Package {#prebuilt-data}

Package [@sap/cds-common-content](https://www.npmjs.com/package/@sap/cds-common-content) provides prebuilt data for the entities `Countries`, `Currencies`, and `Languages`.
Package [@sap/cds-common-content](https://www.npmjs.com/package/@sap/cds-common-content) provides prebuilt data for the entities `Countries`, `Currencies`, `Languages`, and `TimeZones`.

Add it your project:

Expand Down

0 comments on commit c1771fb

Please sign in to comment.