renfe-cli 5.0.0__tar.gz → 5.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.1.0 (2024-10-02)
4
+
5
+ * Enable Renfe Cercanías GTFS dataset [#200](https://github.com/gerardcl/renfe-cli/issues/200)
6
+
3
7
  ## v5.0.0 (2024-09-29)
4
8
 
5
9
  * Major refactor using GTFS data from Renfe online datasets. No more scrapping required
@@ -132,9 +132,9 @@ dependencies = [
132
132
 
133
133
  [[package]]
134
134
  name = "cc"
135
- version = "1.1.22"
135
+ version = "1.1.24"
136
136
  source = "registry+https://github.com/rust-lang/crates.io-index"
137
- checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
137
+ checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
138
138
  dependencies = [
139
139
  "jobserver",
140
140
  "libc",
@@ -462,9 +462,9 @@ dependencies = [
462
462
 
463
463
  [[package]]
464
464
  name = "httparse"
465
- version = "1.9.4"
465
+ version = "1.9.5"
466
466
  source = "registry+https://github.com/rust-lang/crates.io-index"
467
- checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9"
467
+ checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946"
468
468
 
469
469
  [[package]]
470
470
  name = "hyper"
@@ -689,9 +689,12 @@ dependencies = [
689
689
 
690
690
  [[package]]
691
691
  name = "once_cell"
692
- version = "1.19.0"
692
+ version = "1.20.1"
693
693
  source = "registry+https://github.com/rust-lang/crates.io-index"
694
- checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
694
+ checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1"
695
+ dependencies = [
696
+ "portable-atomic",
697
+ ]
695
698
 
696
699
  [[package]]
697
700
  name = "password-hash"
@@ -922,7 +925,7 @@ dependencies = [
922
925
 
923
926
  [[package]]
924
927
  name = "renfe-cli"
925
- version = "5.0.0"
928
+ version = "5.1.0"
926
929
  dependencies = [
927
930
  "chrono",
928
931
  "getopts",
@@ -933,9 +936,9 @@ dependencies = [
933
936
 
934
937
  [[package]]
935
938
  name = "reqwest"
936
- version = "0.12.7"
939
+ version = "0.12.8"
937
940
  source = "registry+https://github.com/rust-lang/crates.io-index"
938
- checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63"
941
+ checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b"
939
942
  dependencies = [
940
943
  "base64",
941
944
  "bytes",
@@ -1026,11 +1029,10 @@ dependencies = [
1026
1029
 
1027
1030
  [[package]]
1028
1031
  name = "rustls-pemfile"
1029
- version = "2.1.3"
1032
+ version = "2.2.0"
1030
1033
  source = "registry+https://github.com/rust-lang/crates.io-index"
1031
- checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425"
1034
+ checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50"
1032
1035
  dependencies = [
1033
- "base64",
1034
1036
  "rustls-pki-types",
1035
1037
  ]
1036
1038
 
@@ -1,13 +1,13 @@
1
1
  [package]
2
2
  name = "renfe-cli"
3
- version = "5.0.0"
3
+ version = "5.1.0"
4
4
  edition = "2021"
5
5
  license = "BSD-3-Clause"
6
6
  description = "CLI for searching Renfe train timetables in the Spanish country"
7
7
  readme = "README.md"
8
8
  homepage = "https://github.com/gerardcl/renfe-cli"
9
9
  repository = "https://github.com/gerardcl/renfe-cli"
10
- keywords = ["cli", "timetables", "trains", "renfe", "spain"]
10
+ keywords = ["cli", "timetables", "schedules", "trains", "renfe", "spain"]
11
11
  categories = ["command-line-utilities"]
12
12
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
13
13
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: renfe-cli
3
- Version: 5.0.0
3
+ Version: 5.1.0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -15,7 +15,6 @@ Classifier: Operating System :: POSIX
15
15
  Classifier: Operating System :: Microsoft :: Windows
16
16
  Classifier: Topic :: Utilities
17
17
  Classifier: Topic :: Terminals
18
- Classifier: Topic :: Text Processing :: Markup :: HTML
19
18
  License-File: LICENSE
20
19
  Summary: Get faster Renfe Spanish Trains timetables in your terminal.
21
20
  Keywords: timetables,schedules,trains,renfe,cli,rust,python,pyo3,maturin
@@ -38,13 +37,15 @@ Project-URL: Changelog, https://github.com/gerardcl/renfe-cli/blob/master/CHANGE
38
37
  Get faster Renfe trains timetables in your terminal, with Python3.7+ support.
39
38
  No longer need to open the browser! Just keep using your terminal 😀
40
39
 
40
+ It supports both [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia) (default option, as in the web) and [Renfe Cercanías](https://data.renfe.com/dataset/horarios-cercanias) GTFS datasets.
41
+
41
42
  `renfe-cli` is written in [Rust](https://www.rust-lang.org/) (since v4.0.0) and published to [pypi.org](https://pypi.org/project/renfe-cli/) as a Python package (CLI and library).
42
43
 
43
44
  See the [changelog](https://github.com/gerardcl/renfe-cli/blob/master/CHANGELOG.md).
44
45
 
45
46
  **NOTE** since I am more often using Rodalies trains I have created [rodalies-cli](https://github.com/gerardcl/rodalies-cli). I hope you like it too!
46
47
 
47
- **DISCLAIMER**: Renfe's GTFS dataset might not be in sync with autonomic train schedules (e.g. Rodalies de la Generalitat de Catalunya), hence Renfe Cercanias train types (e.g.: REGIONAL or MD type) might not be accurate. For that, please use autonomic data/apps (.e.g: [rodalies-cli](https://github.com/gerardcl/rodalies-cli)).
48
+ **DISCLAIMER**: Renfe's GTFS dataset might not be in sync with autonomic train schedules systems (e.g. Rodalies de la Generalitat de Catalunya), hence Renfe Cercanias train types (e.g.: REGIONAL or MD type) might not be accurate, or when using the `cercanias` flag you won't find timetables for the stations belonging to autonomic systems. For that, please use autonomic data/apps (.e.g: [rodalies-cli](https://github.com/gerardcl/rodalies-cli)).
48
49
 
49
50
  ## Installation
50
51
 
@@ -56,7 +57,7 @@ pip install renfe-cli --upgrade
56
57
 
57
58
  ## Usage (CLI)
58
59
 
59
- The CLI uses the official and latest Renfe's GTFS dataset, from [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia).
60
+ The CLI uses the official and latest Renfe's GTFS dataset, from [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia), by default. Optionally, one can enable searching over [Renfe Cercanías GTFS dataset](https://data.renfe.com/dataset/horarios-cercanias) (expect longer load time in this case).
60
61
 
61
62
  ```bash
62
63
  $ renfe-cli -h
@@ -69,16 +70,17 @@ Options:
69
70
  -m, --month MONTH Set the Month (default: today's month)
70
71
  -y, --year YEAR Set the Year (default: today's year)
71
72
  -s, --sort Option to sort the timetable by Duration
73
+ -c, --cercanias Option to search over Renfe Cercanías
72
74
  -h, --help Print this help menu
73
75
  ```
74
76
 
75
77
  ### **Getting the timetable**
76
78
 
77
- Let's show an example of minimal inputs (origin and destination stations) with specific date:
79
+ Let's show an example of minimal inputs (origin and destination stations) with specific date and default GTFS dataset:
78
80
 
79
81
  ```bash
80
82
  $ renfe-cli -f girona -t "puerta de atocha" -d 30
81
- Loading GTFS data from Renfe web
83
+ Loading default GTFS data from Renfe web - Alta velocidad, Larga distancia y Media distancia
82
84
  Provided input 'girona' does a match with 'Estación de tren Girona'
83
85
  Provided input 'puerta de atocha' does a match with 'Estación de tren Madrid-Puerta de Atocha'
84
86
  Today is: 2024-9-29
@@ -103,6 +105,38 @@ Destination station: Estación de tren Madrid-Puerta de Atocha
103
105
  ===========================================================
104
106
  ```
105
107
 
108
+ Let's show an example using Renfe Cercanías GTFS dataset:
109
+
110
+ ```bash
111
+ $ renfe-cli -f chamartín -t "tres cantos" -c
112
+ Loading Cercanías GTFS data from Renfe web - long load time
113
+ Provided input 'chamartín' does a match with 'Station { name: "Estación de tren Madrid-Chamartín-Clara Campoamor", id: "17000" }'
114
+ Provided input 'tres cantos' does a match with 'Station { name: "Estación de tren Tres Cantos (apt)", id: "17004" }'
115
+ Today is: 2024-10-2
116
+ Searching timetable for date: 2024-10-2
117
+ Origin station: Estación de tren Madrid-Chamartín-Clara Campoamor
118
+ Destination station: Estación de tren Tres Cantos (apt)
119
+
120
+ =========================TIMETABLE=========================
121
+ Train | Departure | Arrival | Duration
122
+ -----------------------------------------------------------
123
+ C4b | 05:06 | 05:22 | 00:16
124
+ -----------------------------------------------------------
125
+ C4b | 05:38 | 05:55 | 00:17
126
+ -----------------------------------------------------------
127
+ C4b | 06:10 | 06:27 | 00:17
128
+ -----------------------------------------------------------
129
+ .........
130
+ .........
131
+ -----------------------------------------------------------
132
+ C4b | 21:56 | 22:13 | 00:17
133
+ -----------------------------------------------------------
134
+ C4b | 22:20 | 22:37 | 00:17
135
+ -----------------------------------------------------------
136
+ C4b | 23:16 | 23:33 | 00:17
137
+ ===========================================================
138
+ ```
139
+
106
140
  ## Usage (Library)
107
141
 
108
142
  `renfe-cli` can be imported as a python package into your project, offering utilities when willing to deal with the Renfe search web site.
@@ -115,7 +149,20 @@ Type "help", "copyright", "credits" or "license" for more information.
115
149
  >>> renfe = renfe_cli.
116
150
  renfe_cli.Renfe() renfe_cli.Schedule( renfe_cli.Station( renfe_cli.main() renfe_cli.renfe_cli
117
151
  >>> renfe = renfe_cli.Renfe()
118
- Loading GTFS data from Renfe web
152
+ Traceback (most recent call last):
153
+ File "<stdin>", line 1, in <module>
154
+ TypeError: Renfe.__new__() missing 1 required positional argument: 'cercanias'
155
+ >>> renfe = renfe_cli.Renfe(False)
156
+ Loading default GTFS data from Renfe web - Alta velocidad, Larga distancia y Media distancia
157
+ GTFS data:
158
+ Read in 2171 ms
159
+ Stops: 793
160
+ Routes: 644
161
+ Trips: 4150
162
+ Agencies: 1
163
+ Shapes: 0
164
+ Fare attributes: 0
165
+ Feed info: 0
119
166
  >>> renfe.filter_station("madrid")
120
167
  Traceback (most recent call last):
121
168
  File "<stdin>", line 1, in <module>
@@ -171,10 +218,10 @@ $ maturin develop
171
218
  🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
172
219
  🐍 Not using a specific python interpreter
173
220
  📡 Using build options features from pyproject.toml
174
- Compiling renfe-cli v4.1.0 (/path/to/renfe-cli)
221
+ Compiling renfe-cli v5.1.0 (/path/to/renfe-cli)
175
222
  Finished dev [unoptimized + debuginfo] target(s) in 7.07s
176
- 📦 Built wheel for abi3 Python ≥ 3.7 to /tmp/.tmpDsjowL/renfe_cli-4.1.0-cp37-abi3-linux_x86_64.whl
177
- 🛠 Installed renfe-cli-4.1.0
223
+ 📦 Built wheel for abi3 Python ≥ 3.7 to /tmp/.tmpDsjowL/renfe_cli-5.1.0-cp37-abi3-linux_x86_64.whl
224
+ 🛠 Installed renfe-cli-5.1.0
178
225
  ```
179
226
 
180
227
  Maturin takes care of compiling the rust code, generating the bindings for python and installing the package for local use (as library or binary/CLI).
@@ -5,13 +5,15 @@
5
5
  Get faster Renfe trains timetables in your terminal, with Python3.7+ support.
6
6
  No longer need to open the browser! Just keep using your terminal 😀
7
7
 
8
+ It supports both [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia) (default option, as in the web) and [Renfe Cercanías](https://data.renfe.com/dataset/horarios-cercanias) GTFS datasets.
9
+
8
10
  `renfe-cli` is written in [Rust](https://www.rust-lang.org/) (since v4.0.0) and published to [pypi.org](https://pypi.org/project/renfe-cli/) as a Python package (CLI and library).
9
11
 
10
12
  See the [changelog](https://github.com/gerardcl/renfe-cli/blob/master/CHANGELOG.md).
11
13
 
12
14
  **NOTE** since I am more often using Rodalies trains I have created [rodalies-cli](https://github.com/gerardcl/rodalies-cli). I hope you like it too!
13
15
 
14
- **DISCLAIMER**: Renfe's GTFS dataset might not be in sync with autonomic train schedules (e.g. Rodalies de la Generalitat de Catalunya), hence Renfe Cercanias train types (e.g.: REGIONAL or MD type) might not be accurate. For that, please use autonomic data/apps (.e.g: [rodalies-cli](https://github.com/gerardcl/rodalies-cli)).
16
+ **DISCLAIMER**: Renfe's GTFS dataset might not be in sync with autonomic train schedules systems (e.g. Rodalies de la Generalitat de Catalunya), hence Renfe Cercanias train types (e.g.: REGIONAL or MD type) might not be accurate, or when using the `cercanias` flag you won't find timetables for the stations belonging to autonomic systems. For that, please use autonomic data/apps (.e.g: [rodalies-cli](https://github.com/gerardcl/rodalies-cli)).
15
17
 
16
18
  ## Installation
17
19
 
@@ -23,7 +25,7 @@ pip install renfe-cli --upgrade
23
25
 
24
26
  ## Usage (CLI)
25
27
 
26
- The CLI uses the official and latest Renfe's GTFS dataset, from [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia).
28
+ The CLI uses the official and latest Renfe's GTFS dataset, from [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia), by default. Optionally, one can enable searching over [Renfe Cercanías GTFS dataset](https://data.renfe.com/dataset/horarios-cercanias) (expect longer load time in this case).
27
29
 
28
30
  ```bash
29
31
  $ renfe-cli -h
@@ -36,16 +38,17 @@ Options:
36
38
  -m, --month MONTH Set the Month (default: today's month)
37
39
  -y, --year YEAR Set the Year (default: today's year)
38
40
  -s, --sort Option to sort the timetable by Duration
41
+ -c, --cercanias Option to search over Renfe Cercanías
39
42
  -h, --help Print this help menu
40
43
  ```
41
44
 
42
45
  ### **Getting the timetable**
43
46
 
44
- Let's show an example of minimal inputs (origin and destination stations) with specific date:
47
+ Let's show an example of minimal inputs (origin and destination stations) with specific date and default GTFS dataset:
45
48
 
46
49
  ```bash
47
50
  $ renfe-cli -f girona -t "puerta de atocha" -d 30
48
- Loading GTFS data from Renfe web
51
+ Loading default GTFS data from Renfe web - Alta velocidad, Larga distancia y Media distancia
49
52
  Provided input 'girona' does a match with 'Estación de tren Girona'
50
53
  Provided input 'puerta de atocha' does a match with 'Estación de tren Madrid-Puerta de Atocha'
51
54
  Today is: 2024-9-29
@@ -70,6 +73,38 @@ Destination station: Estación de tren Madrid-Puerta de Atocha
70
73
  ===========================================================
71
74
  ```
72
75
 
76
+ Let's show an example using Renfe Cercanías GTFS dataset:
77
+
78
+ ```bash
79
+ $ renfe-cli -f chamartín -t "tres cantos" -c
80
+ Loading Cercanías GTFS data from Renfe web - long load time
81
+ Provided input 'chamartín' does a match with 'Station { name: "Estación de tren Madrid-Chamartín-Clara Campoamor", id: "17000" }'
82
+ Provided input 'tres cantos' does a match with 'Station { name: "Estación de tren Tres Cantos (apt)", id: "17004" }'
83
+ Today is: 2024-10-2
84
+ Searching timetable for date: 2024-10-2
85
+ Origin station: Estación de tren Madrid-Chamartín-Clara Campoamor
86
+ Destination station: Estación de tren Tres Cantos (apt)
87
+
88
+ =========================TIMETABLE=========================
89
+ Train | Departure | Arrival | Duration
90
+ -----------------------------------------------------------
91
+ C4b | 05:06 | 05:22 | 00:16
92
+ -----------------------------------------------------------
93
+ C4b | 05:38 | 05:55 | 00:17
94
+ -----------------------------------------------------------
95
+ C4b | 06:10 | 06:27 | 00:17
96
+ -----------------------------------------------------------
97
+ .........
98
+ .........
99
+ -----------------------------------------------------------
100
+ C4b | 21:56 | 22:13 | 00:17
101
+ -----------------------------------------------------------
102
+ C4b | 22:20 | 22:37 | 00:17
103
+ -----------------------------------------------------------
104
+ C4b | 23:16 | 23:33 | 00:17
105
+ ===========================================================
106
+ ```
107
+
73
108
  ## Usage (Library)
74
109
 
75
110
  `renfe-cli` can be imported as a python package into your project, offering utilities when willing to deal with the Renfe search web site.
@@ -82,7 +117,20 @@ Type "help", "copyright", "credits" or "license" for more information.
82
117
  >>> renfe = renfe_cli.
83
118
  renfe_cli.Renfe() renfe_cli.Schedule( renfe_cli.Station( renfe_cli.main() renfe_cli.renfe_cli
84
119
  >>> renfe = renfe_cli.Renfe()
85
- Loading GTFS data from Renfe web
120
+ Traceback (most recent call last):
121
+ File "<stdin>", line 1, in <module>
122
+ TypeError: Renfe.__new__() missing 1 required positional argument: 'cercanias'
123
+ >>> renfe = renfe_cli.Renfe(False)
124
+ Loading default GTFS data from Renfe web - Alta velocidad, Larga distancia y Media distancia
125
+ GTFS data:
126
+ Read in 2171 ms
127
+ Stops: 793
128
+ Routes: 644
129
+ Trips: 4150
130
+ Agencies: 1
131
+ Shapes: 0
132
+ Fare attributes: 0
133
+ Feed info: 0
86
134
  >>> renfe.filter_station("madrid")
87
135
  Traceback (most recent call last):
88
136
  File "<stdin>", line 1, in <module>
@@ -138,10 +186,10 @@ $ maturin develop
138
186
  🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
139
187
  🐍 Not using a specific python interpreter
140
188
  📡 Using build options features from pyproject.toml
141
- Compiling renfe-cli v4.1.0 (/path/to/renfe-cli)
189
+ Compiling renfe-cli v5.1.0 (/path/to/renfe-cli)
142
190
  Finished dev [unoptimized + debuginfo] target(s) in 7.07s
143
- 📦 Built wheel for abi3 Python ≥ 3.7 to /tmp/.tmpDsjowL/renfe_cli-4.1.0-cp37-abi3-linux_x86_64.whl
144
- 🛠 Installed renfe-cli-4.1.0
191
+ 📦 Built wheel for abi3 Python ≥ 3.7 to /tmp/.tmpDsjowL/renfe_cli-5.1.0-cp37-abi3-linux_x86_64.whl
192
+ 🛠 Installed renfe-cli-5.1.0
145
193
  ```
146
194
 
147
195
  Maturin takes care of compiling the rust code, generating the bindings for python and installing the package for local use (as library or binary/CLI).
@@ -30,7 +30,6 @@ classifiers = [
30
30
  "Operating System :: Microsoft :: Windows",
31
31
  "Topic :: Utilities",
32
32
  "Topic :: Terminals",
33
- "Topic :: Text Processing :: Markup :: HTML",
34
33
  ]
35
34
  dynamic = ["version"]
36
35
 
@@ -24,7 +24,7 @@ pub fn main() -> PyResult<()> {
24
24
  return Ok(());
25
25
  }
26
26
 
27
- let mut renfe = Renfe::new()?;
27
+ let mut renfe = Renfe::new(matches.opt_present("c"))?;
28
28
 
29
29
  let origin = renfe.filter_station(matches.opt_str("f").expect("Missing origin station"))?;
30
30
  let destination =
@@ -74,6 +74,7 @@ fn set_opts() -> Options {
74
74
  );
75
75
  opts.optopt("y", "year", "Set the Year (default: today's year)", "YEAR");
76
76
  opts.optflag("s", "sort", "Option to sort the timetable by Duration");
77
+ opts.optflag("c", "cercanias", "Option to search over Renfe Cercanías");
77
78
  opts.optflag("h", "help", "Print this help menu");
78
79
 
79
80
  opts
@@ -32,11 +32,18 @@ pub struct Station {
32
32
  #[pymethods]
33
33
  impl Renfe {
34
34
  #[new]
35
- pub fn new() -> PyResult<Self> {
36
- println!("Loading GTFS data from Renfe web");
37
-
35
+ pub fn new(cercanias: bool) -> PyResult<Self> {
38
36
  let mut res = reqwest::blocking::get(
39
- "https://ssl.renfe.com/gtransit/Fichero_AV_LD/google_transit.zip",
37
+ match cercanias {
38
+ false => {
39
+ println!("Loading default GTFS data from Renfe web - Alta velocidad, Larga distancia y Media distancia");
40
+ "https://ssl.renfe.com/gtransit/Fichero_AV_LD/google_transit.zip"
41
+ },
42
+ true => {
43
+ println!("Loading Cercanías GTFS data from Renfe web - long load time");
44
+ "https://ssl.renfe.com/ftransit/Fichero_CER_FOMENTO/fomento_transit.zip"
45
+ },
46
+ },
40
47
  )
41
48
  .expect("Error downloading GTFS zip file");
42
49
  let mut body = Vec::new();
@@ -44,7 +51,8 @@ impl Renfe {
44
51
  let cursor = std::io::Cursor::new(body);
45
52
 
46
53
  let gtfs = Gtfs::from_reader(cursor).expect("Error parsing GTFS zip");
47
- // gtfs.print_stats();
54
+
55
+ gtfs.print_stats();
48
56
 
49
57
  Ok(Renfe {
50
58
  gtfs,
@@ -143,18 +151,22 @@ impl Renfe {
143
151
  let time_origin = origin.departure_time.unwrap();
144
152
  let time_destination = destination.arrival_time.unwrap();
145
153
  let departure_time = NaiveTime::from_hms_opt(
146
- time_origin / 3600,
154
+ (time_origin / 3600) % 24,
147
155
  time_origin % 3600 / 60,
148
156
  time_origin % 60,
149
157
  )
150
158
  .unwrap();
151
159
  let arrival_time = NaiveTime::from_hms_opt(
152
- time_destination / 3600,
160
+ (time_destination / 3600) % 24,
153
161
  time_destination % 3600 / 60,
154
162
  time_destination % 60,
155
163
  )
156
164
  .unwrap();
157
- let duration = arrival_time.signed_duration_since(departure_time);
165
+
166
+ let mut duration = arrival_time.signed_duration_since(departure_time);
167
+ if time_destination >= 86400 {
168
+ duration = duration.checked_add(&TimeDelta::seconds(86400)).unwrap();
169
+ }
158
170
 
159
171
  schedules.push(Schedule {
160
172
  train_type: gtfs
File without changes
File without changes
File without changes
File without changes