Skip to content

Commit 15ea032

Browse files
authored
Fix lookup error for names containing underscores (#50)
Fixes issue #49.
1 parent 6bc8dd0 commit 15ea032

9 files changed

Lines changed: 10685 additions & 1463 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Changes between the versions
22

3-
### 0.2.1
3+
### 0.2.3
4+
5+
* Fix lookup error for names containing underscores
6+
7+
### 0.2.2
48

5-
* Bump dependency version numbers
9+
* Bump dependency versions
610

711
### 0.2.1
812

Cargo.lock

Lines changed: 31 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TZDB_VERSION := tzdb-2022a
44

55
tzdb/src/generated.rs: tmp/${TZDB_VERSION}/usr/share/zoneinfo/
66
cargo r --bin make-tzdb -- $@ $<
7-
cargo fmt
7+
cargo +nightly fmt -- $@
88

99
tmp/${TZDB_VERSION}/usr/share/zoneinfo/: tmp/${TZDB_VERSION}/
1010
cd tmp/${TZDB_VERSION}/ && make PACKRATDATA=backzone TOPDIR="." install

make-tzdb/Cargo.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ authors = ["René Kijewski <crates.io@k6i.de>"]
66
repository = "https://github.com/Kijewski/tzdb"
77
description = "Tool to generate `tzdb/src/generated.rs`"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
[dependencies]
11-
anyhow = "1.0.56"
12-
convert_case = "0.5.0"
13-
indexmap = "1.8.1"
14-
itertools = "0.10.3"
15-
phf_codegen = "0.10.0"
16-
ron = "0.7.0"
17-
serde = { version = "1.0.136", features = ["derive"] }
18-
tz-rs = "0.6.9"
12+
anyhow = "=1"
13+
byte-slice-cast = "=1"
14+
convert_case = "=0.5"
15+
indexmap = "=1"
16+
itertools = "=0.10"
17+
phf_codegen = "=0.10"
18+
phf_shared = "=0.10"
19+
ron = "=0.7"
20+
serde = { version = "=1", features = ["derive"] }
21+
tz-rs = "=0.6"

make-tzdb/src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17+
#[path = "../../tzdb/src/lower.rs"]
18+
mod lower;
1719
mod parse;
1820

1921
use std::cmp::Ordering;
@@ -27,6 +29,8 @@ use indexmap::IndexMap;
2729
use itertools::Itertools;
2830
use tz::TimeZone;
2931

32+
use crate::lower::full_to_lower;
33+
3034
struct TzName {
3135
/// to_pascal("Europe/Belfast")
3236
canon: String,
@@ -198,6 +202,8 @@ pub fn main() -> anyhow::Result<()> {
198202
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
199203
200204
use tz::TimeZoneRef;
205+
#[cfg(feature = "by-name")]
206+
use crate::lower::Lower;
201207
"#
202208
)?;
203209

@@ -253,7 +259,7 @@ use tz::TimeZoneRef;
253259
for entries in entries_by_bytes.values() {
254260
for entry in entries {
255261
phf.entry(
256-
entry.full.to_ascii_lowercase(),
262+
full_to_lower(entry.full.as_bytes()),
257263
&format!("&tzdata::{}", entry.canon),
258264
);
259265
}
@@ -262,7 +268,7 @@ use tz::TimeZoneRef;
262268
writeln!(
263269
f,
264270
"\
265-
pub(crate) const TIME_ZONES_BY_NAME: phf::Map<&'static str, &'static TimeZoneRef<'static>> = {};",
271+
pub(crate) const TIME_ZONES_BY_NAME: phf::Map<Lower, &'static TimeZoneRef<'static>> = {};",
266272
phf.build(),
267273
)?;
268274
writeln!(f)?;
@@ -272,7 +278,7 @@ pub(crate) const TIME_ZONES_BY_NAME: phf::Map<&'static str, &'static TimeZoneRef
272278
for entries in entries_by_bytes.values() {
273279
for entry in entries {
274280
phf.entry(
275-
entry.full.to_ascii_lowercase(),
281+
full_to_lower(entry.full.as_bytes()),
276282
&format!("raw_tzdata::{}", entry.canon),
277283
);
278284
}
@@ -281,7 +287,7 @@ pub(crate) const TIME_ZONES_BY_NAME: phf::Map<&'static str, &'static TimeZoneRef
281287
writeln!(
282288
f,
283289
"\
284-
pub(crate) const RAW_TIME_ZONES_BY_NAME: phf::Map<&'static str, &'static [u8]> = {};",
290+
pub(crate) const RAW_TIME_ZONES_BY_NAME: phf::Map<Lower, &'static [u8]> = {};",
285291
phf.build(),
286292
)?;
287293
writeln!(f)?;

tzdb/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tzdb"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
edition = "2021"
55
authors = ["René Kijewski <crates.io@k6i.de>"]
66
repository = "https://github.com/Kijewski/tzdb"
@@ -15,20 +15,21 @@ rust-version = "1.57"
1515
tz-rs = { version = "0.6.9", features = ["const"] }
1616

1717
# optional dependencies
18-
byte-slice-cast = { version = "1.2.1", optional = true }
19-
iana-time-zone = { version = "0.1.33", optional = true }
20-
phf = { version = "0.10.1", optional = true }
21-
serde = { version = "1.0.136", default-features = false, optional = true }
22-
serde_with = { version = "1.12.1", default-features = false, optional = true }
18+
byte-slice-cast = { version = "=1", optional = true }
19+
iana-time-zone = { version = "=0.1", optional = true }
20+
phf = { version = "=0.10", optional = true }
21+
phf_shared = { version = "=0.10", optional = true }
22+
serde = { version = "=1", default-features = false, optional = true }
23+
serde_with = { version = "=1", default-features = false, optional = true }
2324

2425
[dev-dependencies]
25-
serde_json = "1.0.79"
26+
serde_json = "=1"
2627

2728
[features]
2829
default = ["by-name", "list", "local"]
2930
## enables [tz_by_name()] to get a time zone at runtime by name
3031
##
31-
by-name = ["phf", "byte-slice-cast"]
32+
by-name = ["phf", "phf_shared", "byte-slice-cast"]
3233
## enables [TZ_NAMES] to get a list of all shipped time zones
3334
##
3435
list = []

0 commit comments

Comments
 (0)