aboutsummaryrefslogtreecommitdiff
path: root/timetolocal.c
diff options
context:
space:
mode:
authordavid <[email protected]>2026-09-28 12:46:41 -0300
committerdavid <[email protected]>2026-09-28 12:46:41 -0300
commit1535072cc90c95e2b580f7394244300309f69dc2 (patch)
tree93c06a0cdbfdff6fb14e57a2dfa995c2f402d1e2 /timetolocal.c
parentc315d1d2b3ea9e42045e402564da344dde30fab4 (diff)
downloadtimetolocal-1535072cc90c95e2b580f7394244300309f69dc2.tar.gz
timetolocal-1535072cc90c95e2b580f7394244300309f69dc2.zip
oh okay yeah there was a bug here
Diffstat (limited to 'timetolocal.c')
-rw-r--r--timetolocal.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/timetolocal.c b/timetolocal.c
index fce07d1..4b81335 100644
--- a/timetolocal.c
+++ b/timetolocal.c
@@ -47,22 +47,24 @@ int convert(char *timey, char *zone){
//this sould take even daylight savings too, i stole it from stack overflow i've been trying to not use llms to code shit like this
//tmzn hour --> utc00 --> local time
- if(findintable(zone)== -1){
- return -1;
- }
int zntime = findintable(zone);
+ if(zntime == -1)return -1;
davidtime eugh = strtimetoint(timey);
- int zonetimeminutes = (eugh.hour*60)+eugh.minutes;
- int normalizedminutes = zonetimeminutes+(zntime*-1); //utc00
-
- int localminutes = (normalizedminutes+offset) % 1440;
+ int total = eugh.hour * 60 + eugh.minutes - zntime + offset; //ok this is better yeah
+
+ int day = 0;
+ while (total < 0){
+ total += 1440; day--;
+ }
+ while (total >= 1440){
+ total -= 1440; day++;
+ }
- davidtime finally;
- finally.hour = localminutes/60;
- finally.minutes = localminutes - finally.hour*60;
- printf("%02d:%02d\n",finally.hour,finally.minutes);
- return 0;
+ printf("%02d:%02d", total / 60, total % 60);
+ if(day) printf(" %+dd", day);
+ printf("\n");
+ return 0;
}
int main (int argc, char **argv){