Ollama working with deepseek-r1, deepseek-coder, mistral, Nvidia gpu and emacs with gptel on Freebsd 14.2

id be interested if anyone who knows c would evaluate the response and see how far off it was
The code looks pretty ugly. While parse_time() isn't complete nonsense, it's still easier to drop it and rewrite from scratch. convert_time() isn't any better. For instance, it either returns the number of hours or just 11, based on fraction it couldn't even calculate because it receives seconds as input. The number 11 here is a whole another mess - for some reason it's supposed to be the length of the "HH:MM:SS.mm" string, which always will be, you know... 11. The data types are also a complete disaster.

In short, I doubt you'll be able to fix this program without at least some understanding of C. If you do know C, though, you'll probably have a lot more fun just writing it yourself. It might be faster, too.
 
i dont know any c but the code looked a bit iffy even to me
also tried getting deepseek to rewrite the script using rust but that didnt work either

i wasnt actually trying to rewrite the script as a c program
just thought it would be a good test

looks like the ai overlords wont be taking over for a while
 
DeepSeek, the viral AI company, has released a new set of multimodal AI models that it claims can outperform OpenAI’s DALL-E 3.
The models, which are available for download from the AI dev platform Hugging Face, are part of a new model family that DeepSeek is calling Janus-Pro.



github

 
looks like janus uses python and torch

i never managed to get torch working in a linux jail

search for torch with pkg

Code:
pkg search torch

Code:
py311-facenet-pytorch-2.5.3    Pretrained PyTorch face detection and recognition models
py311-pytorch-2.5.1_1          PyTorch: Tensors and dynamic neural networks in Python
py311-pytorch-lightning-2.3.3  Lightweight PyTorch wrapper for ML researchers
py311-pytorchvideo-0.1.5_2     Video understanding deep learning library
py311-torch-geometric-2.6.1    Graph neural network library for PyTorch
py311-torchaudio-2.2.1_6       PyTorch-based audio signal processing and machine learning library
py311-torchmetrics-1.6.0       PyTorch native metrics
py311-torchvision-0.20.1       PyTorch: Datasets, transforms and models specific to computer vision
pytorch-2.4.1_2                Tensors and dynamic neural networks in Python (C++ library)

does anyone know if the freebsd torch pkgs work

i guess the issue might be they use python 3.11

so you would have to create a python 3.11 virtual env
either using miniconda or python venv to create the virtual env

they are a couple of other tools like WhisperX or Melotts
i tried to install in a linux jail but didnt work due to cuda wrong os type errors or something

would be good to get torch working to play around with some of these tools

looks like they are using python 3.8

On the basis of Python >= 3.8 environment, install the necessary dependencies by running the following command:
 
thinking out load

i wonder if torch will work in a linux byhve vm with my gpu

however i only have one gpu,
so i cant disable the gpu to pass through to the byhve vm
 
i wonder if torch will work in a linux byhve vm with my gpu
Ill keep you updated .. i have my Volta gpu doing nothing as im trying to understand how to patch FreeBSD so i can get bhyve with gpu passtrough running. but i have issue - i dont understand what to do ( patching and making bhyve ) ....yet and today i have time to get it done so maybe towards evening or tomorrow i will know if im succeeded. lol.
 
thinking out load

i wonder if torch will work in a linux byhve vm with my gpu

however i only have one gpu,
so i cant disable the gpu to pass through to the byhve vm
Arent't there docking stations with their own GPU? Could that be an option? Since they never really took off (at least I never saw them in the wild), they might be available cheaply on $FLEA_MARKET
 
No the correct way is to do bhyve pass-through but NapoleonWils0n is really pushing that laptop of his.... I will give this a try when I have some time (I have 4 GPU on my Box) for testing purposes try to get Pytorch running in Bhyve with GPU Pass-through (if someone beats me to this the better ;) ).
 
get Pytorch running in Bhyve with GPU Pass-through (if someone beats me to this the better ;) ).

thats exactly what im trying to get working as well
pytorch with gpu passthru

pytorch fail to work in a linux jail due to cuda wrong os errors
 
didnt have much luck with passing thru the gpu without masking it

 
sound simple when you put it like that

have you got any links you could throw my way
otherwise back to the dreaded google
Basically, it is a matter to build the following on FreeBSD (available in ports, but without the venus and the drm-renderers options )


With the venus option in order to accelerate vulkan backend (in addition to the opengl backend) and the drm-renderers option (for now it seems there is amdgpu-experimental and msm).
And of course you need a way to serialize the data between the VM and the guest.
As of now, only the OpenGL backend build on FreeBSD. And can be serialized with the help of socat (but it is really slow).

And of course you cannot really test it with FreeBSD guest since our mesa driver is not built for virtio gpu support.

PS: this note seems to be interesting

 
1 - deepseek-r1:7b

ollama run --verbose deepseek-r1:7b
prompt


total duration: 1m8.189666221s load duration: 100.87756ms prompt eval count: 12 token(s) prompt eval duration: 1.847238s prompt eval rate: 6.50 tokens/s eval count: 273 token(s) eval duration: 1m6.160223s eval rate: 4.13 tokens/s
I got 71.57 t/s running same model.
 
deepseek-r1:7b programming prompt

sexagesimal-time script
calculate sexagesimal duration by subtacting end time from start time



Code:
#!/bin/sh

#===============================================================================
# sexagesimal-time
# calculate sexagesimal duration by subtacting end time from start time
#===============================================================================

# dependencies:
# awk

#===============================================================================
# script usage
#===============================================================================

usage () {
# if argument passed to function echo it
[ -z "${1}" ] || echo "! ${1}"
# display help
echo "\
calculate sexagesimal duration by subtacting end time from start time
$(basename "$0") -s 00:00:00 -e 00:00:00"
exit 2
}


#===============================================================================
# error messages
#===============================================================================

INVALID_OPT_ERR='Invalid option:'
REQ_ARG_ERR='requires an argument'
WRONG_ARGS_ERR='wrong number of arguments passed to script'


#===============================================================================
# check the number of arguments passed to the script
#===============================================================================

[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}"


#===============================================================================
# getopts check the options passed to the script
#===============================================================================

while getopts ':s:e:h' opt
do
  case ${opt} in
     s) start="${OPTARG}";;
     h) usage;;
     e) end="${OPTARG}";;
     \?) usage "${INVALID_OPT_ERR} ${OPTARG}" 1>&2;;
     :) usage "${INVALID_OPT_ERR} ${OPTARG} ${REQ_ARG_ERR}" 1>&2;;
  esac
done
shift $((OPTIND-1))


#===============================================================================
# function
#===============================================================================

sexagesimal () {
printf "%s %s\n" "${start}" "${end}" \
| awk '
        {
          start = $1
          end = $2
          if (start ~ /:/) {
            split(start, t, ":")
            sseconds = (t[1] * 3600) + (t[2] * 60) + t[3]
          }
          if (end ~ /:/) {
            split(end, t, ":")
            eseconds = (t[1] * 3600) + (t[2] * 60) + t[3]
          }
          duration = eseconds - sseconds
          printf("%s\n"), duration
     }' \
| awk -F. 'NF==1 { printf("%02d:%02d:%02d\n"), ($1 / 3600), ($1 % 3600 / 60), ($1 % 60) }\
NF==2 { printf("%02d:%02d:%02d.%s\n"), ($1 / 3600), ($1 % 3600 / 60), ($1 % 60), ($2) }'
}


#===============================================================================
# run function
#===============================================================================

sexagesimal

and this is the response from deepseek-r1:7b

<think>
Okay, so I need to convert a given shell script into a C program. The original script is called sexagesimal-time and it's supposed to calculate the duration between two times in sexagesimal format (hours:minutes:seconds).

First, let me understand what the script does. It uses 'awk' to process the input times. The main function seems to parse the start and end times, convert them into total seconds, subtract to get the duration, and then convert back to hours, minutes, and seconds for output.

Now, I need to translate this logic into C. I'll structure the code with functions similar to how they were used in the script. The main steps are:

1. *Function Definitions*:
- A function to read command line arguments.
- A function to check options using getopts.
- A sexagesimal conversion function that handles input parsing and calculation.

2. *Argument Handling*:
- Ensure exactly two time strings are provided (start and end).
- Use 'getopt' functions to handle the '-s', '-e', and '-h' options, with error checking if options are invalid or too many arguments.

3. *Parsing Times*:
- Each time string is split into hours, minutes, seconds.
- Convert these into total seconds for calculation.

4. *Duration Calculation*:
- Subtract start_seconds from end_seconds to get the duration in seconds.

5. *Formatting Output*:
- Convert the total duration back into hh:mm:ss format with leading zeros where necessary.

6. *Error Handling*:
- Check that exactly two arguments are provided.
- Ensure that if optional flags are used, they don't cause issues.

I'll start by writing the main function which checks for command line options and arguments. Then, define the sexagesimal_time function to handle the time parsing and calculation.

In the sexagesimal_time function, I'll write helper functions parse_time and convert_time. Parse_time will split a time string into components and convert them into seconds. Convert_time will take total seconds and format them back into hh:mm:ss.

I need to make sure that all possible cases are handled, like when hours exceed 24 (so output is something like 25:01:30) or when the duration is negative (though in this case, maybe it's impossible as per script usage).

Testing with examples should help. For instance, if start is "8:15:30" and end is "9:45:59", the duration should be 1:30:29.

I also need to ensure that the program exits correctly with non-zero status codes for errors like invalid options or incorrect number of arguments.

Finally, I'll compile all these functions into a C program, ensuring that main() calls them appropriately after command line argument parsing and option handling.
</think>

this is the c code it came up with

Code:
#include <stdio.h>
#include <stdlib.h>

void usage(const char *message) {
    printf("%s\n", message);
    exit(EXIT_FAILURE);
}

int sexagesimal_time(char *start, char *end) {
    int64_t start_seconds = parse_time(start);
    int64_t end_seconds = parse_time(end);

    if (start_seconds > end_seconds) {
        return -1;
    }

    int64_t duration = end_seconds - start_seconds;

    return convert_time(duration);
}

int* parse_time(const char *time) {
    const char *part[3];
    int64_t total = 0;

    if (strspn(time, ": ") == 0) {
        part[0] = time;
        return &total;
    }

    part[1] = strchr(time, ':')[0];
    part[2] = time[strlen(time)-1];

    int64_t hours = stol(part[1]);
    int64_t minutes = stol(part[2]);
    int64_t seconds = 0;

    total += hours * 3600;
    total += minutes * 60;
    total += seconds;

    return &total;
}

int* convert_time(int64_t seconds) {
    int64_t h, m, s, d;

    if (seconds < 0) {
        // Return error value
        return NULL;
    }

    h = seconds / 3600;
    m = (seconds % 3600) / 60;
    s = seconds % 60;

    // Add fractional part if needed?
    int64_t fraction = seconds - ((int64_t)h * 3600 + (int64_t)m * 60 + (int64_t)s);

    if (!fraction) {
        return &h;
    } else {
        char buf[18];
        snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%02d", h, m, s, fraction);
        return &buf_strlen(buf);
    }
}

int main(int argc, char **argv) {
    if (argc != 3 || argv[1] == NULL || argv[2] == NULL) {
        usage("invalid number of arguments");
    }

    char start_time[100];
    printf("Enter start time in 'hh:mm:ss' format: ");
    if (!fgets(start_time, sizeof(start_time), stdin)) {
        return usage("Failed to read input");
    }

    char end_time[100];
    printf("Enter end time in 'hh:mm:ss' format: ");
    if (!fgets(end_time, sizeof(end_time), stdin)) {
        return usage("Failed to read input");
    }

    int64_t result = sexagesimal_time(start_time, end_time);

    switch (result) {
        case -1:
            exit(EXIT_FAILURE);
        default:
            char *output;
            if (output = convert_time(result)) {
                printf("%s\n", output);
                free(output);
            } else {
                printf("Invalid time format\n");
            }
            exit(EXIT_SUCCESS);
    }

    return 0;
}

compile

Code:
cc -o sexagesimal-time sexagesimal-time.c

errors

Code:
sexy-time.c:10:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   10 |     int64_t start_seconds = parse_time(start);
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:10:29: warning: call to undeclared function 'parse_time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   10 |     int64_t start_seconds = parse_time(start);
      |                             ^
sexy-time.c:11:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   11 |     int64_t end_seconds = parse_time(end);
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:17:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   17 |     int64_t duration = end_seconds - start_seconds;
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:19:12: warning: call to undeclared function 'convert_time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   19 |     return convert_time(duration);
      |            ^
sexy-time.c:22:6: error: conflicting types for 'parse_time'
   22 | int* parse_time(const char *time) {
      |      ^
sexy-time.c:10:29: note: previous implicit declaration is here
   10 |     int64_t start_seconds = parse_time(start);
      |                             ^
sexy-time.c:24:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   24 |     int64_t total = 0;
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:26:9: warning: call to undeclared library function 'strspn' with type 'unsigned long (const char *, const char *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   26 |     if (strspn(time, ": ") == 0) {
      |         ^
sexy-time.c:26:9: note: include the header <string.h> or explicitly provide a declaration for 'strspn'
sexy-time.c:28:16: warning: incompatible pointer types returning '__int64_t *' (aka 'long *') from a function with result type 'int *' [-Wincompatible-pointer-types]
   28 |         return &total;
      |                ^~~~~~
sexy-time.c:28:17: warning: address of stack memory associated with local variable 'total' returned [-Wreturn-stack-address]
   28 |         return &total;
      |                 ^~~~~
sexy-time.c:31:15: warning: call to undeclared library function 'strchr' with type 'char *(const char *, int)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   31 |     part[1] = strchr(time, ':')[0];
      |               ^
sexy-time.c:31:15: note: include the header <string.h> or explicitly provide a declaration for 'strchr'
sexy-time.c:31:13: error: incompatible integer to pointer conversion assigning to 'const char *' from 'char'; take the address with & [-Wint-conversion]
   31 |     part[1] = strchr(time, ':')[0];
      |             ^ ~~~~~~~~~~~~~~~~~~~~
      |               &
sexy-time.c:32:20: warning: call to undeclared library function 'strlen' with type 'unsigned long (const char *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   32 |     part[2] = time[strlen(time)-1];
      |                    ^
sexy-time.c:32:20: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
sexy-time.c:32:13: error: incompatible integer to pointer conversion assigning to 'const char *' from 'const char'; take the address with & [-Wint-conversion]
   32 |     part[2] = time[strlen(time)-1];
      |             ^ ~~~~~~~~~~~~~~~~~~~~
      |               &
sexy-time.c:34:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   34 |     int64_t hours = stol(part[1]);
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:34:21: warning: call to undeclared function 'stol'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   34 |     int64_t hours = stol(part[1]);
      |                     ^
sexy-time.c:35:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   35 |     int64_t minutes = stol(part[2]);
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:36:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   36 |     int64_t seconds = 0;
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:42:12: warning: incompatible pointer types returning '__int64_t *' (aka 'long *') from a function with result type 'int *' [-Wincompatible-pointer-types]
   42 |     return &total;
      |            ^~~~~~
sexy-time.c:42:13: warning: address of stack memory associated with local variable 'total' returned [-Wreturn-stack-address]
   42 |     return &total;
      |             ^~~~~
sexy-time.c:45:19: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   45 | int* convert_time(int64_t seconds) {
      |                   ^~~~~~~
      |                   __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:45:6: error: conflicting types for 'convert_time'
   45 | int* convert_time(int64_t seconds) {
      |      ^
sexy-time.c:19:12: note: previous implicit declaration is here
   19 |     return convert_time(duration);
      |            ^
sexy-time.c:46:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   46 |     int64_t h, m, s, d;
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:58:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   58 |     int64_t fraction = seconds - ((int64_t)h * 3600 + (int64_t)m * 60 + (int64_t)s);
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:58:36: error: use of undeclared identifier 'int64_t'
   58 |     int64_t fraction = seconds - ((int64_t)h * 3600 + (int64_t)m * 60 + (int64_t)s);
      |                                    ^
sexy-time.c:61:16: warning: incompatible pointer types returning '__int64_t *' (aka 'long *') from a function with result type 'int *' [-Wincompatible-pointer-types]
   61 |         return &h;
      |                ^~
sexy-time.c:61:17: warning: address of stack memory associated with local variable 'h' returned [-Wreturn-stack-address]
   61 |         return &h;
      |                 ^
sexy-time.c:64:59: warning: format specifies type 'int' but the argument has type '__int64_t' (aka 'long') [-Wformat]
   64 |         snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%02d", h, m, s, fraction);
      |                                     ~~~~                  ^
      |                                     %02ld
sexy-time.c:64:62: warning: format specifies type 'int' but the argument has type '__int64_t' (aka 'long') [-Wformat]
   64 |         snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%02d", h, m, s, fraction);
      |                                          ~~~~                ^
      |                                          %02ld
sexy-time.c:64:65: warning: format specifies type 'int' but the argument has type '__int64_t' (aka 'long') [-Wformat]
   64 |         snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%02d", h, m, s, fraction);
      |                                               ~~~~              ^
      |                                               %02ld
sexy-time.c:64:68: warning: format specifies type 'int' but the argument has type '__int64_t' (aka 'long') [-Wformat]
   64 |         snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%02d", h, m, s, fraction);
      |                                                    ~~~~            ^~~~~~~~
      |                                                    %02ld
sexy-time.c:65:17: warning: call to undeclared function 'buf_strlen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   65 |         return &buf_strlen(buf);
      |                 ^
sexy-time.c:65:16: error: cannot take the address of an rvalue of type 'int'
   65 |         return &buf_strlen(buf);
      |                ^~~~~~~~~~~~~~~~
sexy-time.c:77:16: error: returning 'void' from a function with incompatible result type 'int'
   77 |         return usage("Failed to read input");
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sexy-time.c:83:16: error: returning 'void' from a function with incompatible result type 'int'
   83 |         return usage("Failed to read input");
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sexy-time.c:86:5: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   86 |     int64_t result = sexagesimal_time(start_time, end_time);
      |     ^~~~~~~
      |     __int64_t
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
sexy-time.c:92:13: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
   92 |             char *output;
      |             ^
sexy-time.c:93:24: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
   93 |             if (output = convert_time(result)) {
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sexy-time.c:93:24: note: place parentheses around the assignment to silence this warning
   93 |             if (output = convert_time(result)) {
      |                        ^
      |                 (                            )
sexy-time.c:93:24: note: use '==' to turn this assignment into an equality comparison
   93 |             if (output = convert_time(result)) {
      |                        ^
      |                        ==
19 warnings and 19 errors generated.

i thought it would an interesting test trying to convert a shell script into a c program

i dont know any c,
so i couldnt say how close it got to create a working c version of the script

id be interested if anyone who knows c would evaluate the response and see how far off it was
I asked this one for 7b param one and 33b param.
7b param did very quickly.
33b - well - still going, waiting for it to end.

but fast .and while i was typing this comment - its over.
22t/s .
gpu utilization 91%-93% ... up to 180 W of power usage.

I do recall Deepseek wrote their own code in assembly instead of using CUDA.... legends !
Code:
total duration:       9m3.886916652s
load duration:        23.169628ms
prompt eval count:    27 token(s)
prompt eval duration: 96ms
prompt eval rate:     281.25 tokens/s
eval count:           11992 token(s)
eval duration:        9m3.765s
eval rate:            22.05 tokens/s
Lets see if im able to make a answer ...
 
Code:
evo@debian-bhyve:~$ ollama run deepseek-r1:32b --verbose
>>> calculate sexadesimal duartion by substacting end time from start time. convert the following script into a c program
<think>
Okay, so I need to figure out how to calculate the duration between two times given in sexagesimal format and then
write a C program for it. Let's break this down step by step.

First, I know that sexagesimal time uses hours, minutes, seconds, and fractions of a second. The example given is Start
Time: 12h50m30s.75 and End Time: 13h15m45s.60. The duration should be 1 hour 25 minutes 14.85 seconds.

Hmm, how do I handle the conversion? Maybe convert each time to total seconds including fractions, subtract them, then
convert back to hours, minutes, and seconds.

Let's think about the structure of the input. Each time is in the format hh:mm:ss.ss. So for Start Time: 12h50m30s.75,
that's 12 hours, 50 minutes, 30 seconds, and 0.75 seconds.

Wait, actually, no—the .75 would be 75 hundredths of a second, right? Or is it 0.75 seconds? I think in the example,
they treated 0.75 as fractions of a second. So maybe each time is split into hours, minutes, seconds, and fractional
parts.

So for both start and end times, I need to parse these components: hours, minutes, seconds, and the fractional part
(maybe two decimal places). Then convert each to total seconds with fractions.

For example:
- Start Time: 12h50m30s.75
  - Hours = 12 * 3600 = 43200 seconds
  - Minutes = 50 * 60 = 3000 seconds
  - Seconds = 30 + 0.75 = 30.75 seconds
  - Total = 43200 + 3000 + 30.75 = 46230.75 seconds

- End Time: 13h15m45s.60
  - Hours = 13 * 3600 = 46800 seconds
  - Minutes = 15 * 60 = 900 seconds
  - Seconds = 45 + 0.60 = 45.60 seconds
  - Total = 46800 + 900 + 45.60 = 47745.60 seconds

Subtracting start from end: 47745.60 - 46230.75 = 1514.85 seconds.

Then, convert 1514.85 seconds back to hh:mm:ss.ss:
- Hours: 1514.85 / 3600 ≈ 0.4208 hours → 0h
- Remaining seconds: 1514.85 - (0 * 3600) = 1514.85 seconds
- Minutes: 1514.85 / 60 ≈ 25.2475 minutes → 25m, remaining seconds 14.85s

So the duration is 0h25m14.85s.

Okay, so in code, I need to:

1. Read two time strings.
2. Parse each string into hours, minutes, seconds, and fractional parts.
3. Convert each to total seconds (including fractions).
4. Subtract start from end to get duration in seconds.
5. Convert the duration back into hh:mm:ss.ss format.

How to parse the input? Each time is a string like "12h50m30s.75". So I can split on 'h', then take the next part as
minutes, and so on.

But wait, in C, handling strings can be a bit tricky. Maybe use sscanf with the appropriate format specifier.

For example:
sscanf(time_str, "%dh%dm%ds.%2f", &hours, &minutes, &seconds_fraction);

Wait, but that would split into hours, minutes, seconds, and fractional part as two digits? Or perhaps it's better to
read the entire seconds part including the decimal as a float.

Alternatively, parse each component step by step.

Another approach: Split the string on 'h', then the first part is hours. The remaining string can be processed for
minutes, etc.

But that might complicate things. Maybe using sscanf with format "%d:%d:%f", but the time has h, m, s. So perhaps
something like:

char *str = "12h50m30s.75";
sscanf(str, "%dh%dm%ds.%2f", &h, &m, &s, &frac);

Wait, does sscanf support this? Let me think: the format string would look for digits before 'h', then after 'h' digits
before 'm', etc.

Yes, I think that's possible. So in code:

char start_time[] = "12h50m30s.75";
double h, m, s, frac;
sscanf(start_time, "%lfh%lfm%lfs.%lf", &h, &m, &s, &frac);

Wait, but the fractional part is only two digits in the example. So maybe read it as a string and parse accordingly.

Alternatively, perhaps using more precise parsing:

Split the string into parts based on 'h', 'm', 's', etc. But that might be complicated without using complex functions.

Another idea: Use sscanf with format "%d:%d:%lf", but considering that the time is given in h:m:s.ss format.

Wait, no—the input includes h, m, s as part of the string, not separated by colons. So perhaps:

sscanf(time_str, "%dh%dm%ds.%2f", &hours, &minutes, &seconds, &fraction);

But I'm not sure if sscanf can handle this directly because 'h', 'm', and 's' are delimiters, not part of the format.

Wait, in C, the %d format specifier will read digits until a non-digit is found. So for "12h50m30s.75", using
"%dh%dm%ds.%lf" would work?

Let me test that: sscanf("12h50m30s.75", "%dh%dm%ds.%lf", &h, &m, &s, &frac). That should give h=12, m=50, s=30,
frac=0.75.

Yes, that seems correct.

So in code:

double hours, minutes, seconds, fractional;
sscanf(time_str, "%lfh%lfm%lfs.%lf", &hours, &minutes, &seconds, &fractional);

Wait, but the fractional part is after the decimal point in the 's' component. So for "12h50m30s.75", s=30 and
fraction=75? Or is it 30.75 seconds?

Hmm, perhaps I should read the seconds as a float including the fraction.

Alternatively, perhaps:

sscanf(time_str, "%lfh%lfm%lfs", &hours, &minutes, &seconds);

But then how to get the fractional part after 's.' ?

Wait, maybe split the string into two parts: before and after the '.' in seconds.

For example:

char *dot = strchr(time_str, '.');
if (dot) {
    *dot = '\0';
    // parse up to here
    sscanf(time_str, "%lfh%lfm%lfs", &hours, &minutes, &seconds);
    // then parse the fraction part after dot
    char fraction_str[3];
    strncpy(fraction_str, dot+1, 2); // assuming two digits
    fraction_str[2] = '\0';
    double fractional = atof(fraction_str) / 100.0;
} else {
    // no fractional seconds
}

This way, for "12h50m30s.75", the code would read hours=12, minutes=50, seconds=30, and fractional=0.75.

Yes, this approach might be more reliable because sscanf with %lf may not correctly parse the string if there are
multiple delimiters.

So in code:

For each time string (start and end):

- Find the '.' to separate the seconds into integer and fractional parts.
- Parse hours, minutes, seconds as integers before the '.'
- Parse the two digits after '.' as fractional seconds (divided by 100).

Once I have the total seconds for start and end times, subtract them to get duration in seconds.

Then convert that duration back to hh:mm:ss.ss format.

To convert back:

total_seconds = difference;

hours_duration = (int)(total_seconds / 3600);
remaining = total_seconds % 3600;
minutes_duration = (int)(remaining / 60);
seconds_duration = remaining % 60;

But since the duration can have fractions, we need to handle that.

Wait, let's take an example:

Total seconds: 1514.85

hours_duration = 1514.85 / 3600 → 0
remaining = 1514.85
minutes_duration = 1514.85 / 60 → 25.2475 → integer part is 25, remaining seconds: 14.85

So hours=0, minutes=25, seconds=14.85.

But in the code, how to handle this:

double total_seconds = ...;
int hours = (int)(total_seconds / 3600);
double remaining = total_seconds - hours*3600;

int minutes = (int)(remaining / 60);
double sec_remaining = remaining - minutes *60;

So for the duration, it's:

hours_duration = hours
minutes_duration = minutes
seconds_fractional = sec_remaining

Then format this as hh:mm:ss.ss.

But since the problem is to calculate and present the difference, perhaps we can represent it in sexagesimal format.

Wait, but maybe more accurately: when converting total_seconds back into h:m:s, considering that fractional seconds may
carry over into minutes or hours.

For example, if duration is 3661.25 seconds:

hours = 1 (3600), remaining=61.25

minutes = 1, remaining=1.25 → total would be 1:01:01.25.

But in our case, the duration may not exceed a day or anything like that.

So code steps:

Read start_time and end_time as strings.

For each time string:

- Find if there is a '.' to split into seconds and fractional part.
- Parse hours, minutes, seconds as integers before the '.' (if any).
- Parse the two digits after '.' as fractional seconds / 100.0.

Calculate total_seconds_start = hours*3600 + minutes*60 + seconds + fractional.

Same for end_time: total_seconds_end.

Compute difference = total_seconds_end - total_seconds_start.

If difference is negative, perhaps adjust by adding 86400 to make it positive (assuming time wraps around a day). Or
maybe the problem assumes that end_time is after start_time.

Assuming end_time is later than start_time.

Then convert difference into h:mm:ss.ss.

So now, implement this in code.

But wait, what if the difference is more than 24 hours? The output would still represent it as a duration with possibly
multiple days. But perhaps the problem expects just the time difference within a day.

Alternatively, for the calculation, the result can be any positive or negative value.

Wait, but in the example given:

If start_time is 01h30m45s.78 and end_time is same as start_time, difference is zero. If end_time is earlier than
start_time, we need to handle that by subtracting.

But perhaps for this problem, it's assumed that end_time is later than start_time.

Alternatively, the code can compute the absolute value of the difference.

But let me think about how to structure the program.

Read two time strings: start and end.

Parse each into total_seconds_start and total_seconds_end.

Compute difference = total_seconds_end - total_seconds_start.

If difference < 0, add 86400 (24*3600) to make it positive? Or perhaps not. Depends on whether the times are within the
same day or not.

But without knowing if they cross midnight, it's difficult.

Alternatively, just compute the difference as is, which can be negative.

Then, when converting back into hh:mm:ss.ss, we need to handle cases where hours could be zero or positive or even
multiple days.

For example:

If difference is 3601.5 seconds → 1:00:01.5

Difference of -10 seconds → maybe -0h:-0m:-10s (but that's not meaningful). So perhaps better to compute the absolute
value?

But for now, assuming end_time >= start_time.

So code steps:

Read two time strings.

Parse each into total_seconds.

Compute difference = end - start.

If difference < 0: difference += 86400; ?

Not sure. Maybe not necessary unless the problem specifies that times can be on different days.

But without that, perhaps proceed as is.

Now, how to parse the time string correctly.

Sample input:

start_time = "01h30m45s.78"

We need to extract h=1, m=30, s=45.78?

Wait no: '45s.78' would be 45 + 0.78 seconds? Or is it 45.something.

Yes, the fractional part after 's.' is hundredths of a second.

So for "45s.78", that's 45.78 seconds.

Thus, in code:

For each time string, split into h, m, s parts.

For example, split on 'h', then on 'm', then on 's'.

Then process each part:

- The first part is hours (could be like "01", which is 1 hour)
- The second part after 'h' and before 'm' is minutes ("30" → 30 min)
- The third part after 'm' and before 's.' is seconds: "45" in this case
- Then, check if there's a fractional part after 's.': ".78" → add 0.78 to seconds.

But wait: the time string can be like "1h2m3.456s"?

No, because the original example has "01h30m45s.78", which is two digits for each part and a fractional part of two
digits after s.

Assuming that in the input strings, the format is always hh, mm, ss[.cc], where cc are hundredths of a second.

But perhaps better to parse more flexibly.

So code steps:

Parse each time string into hours, minutes, seconds (including fractional).

Possible approach in Python:

Split the string on 'h', 'm', 's' etc., then process parts accordingly.

For example, for "01h30m45s.78":

- Split at 'h' → ["01", "30m45s.78"]
- Then split at 'm' in the second part: ["30", "45s.78"]
- Then split at 's.' in the third part: ["45", ".78"]

So hours = 1, minutes=30, seconds=45 + 0.78.

Another example: "2h5m6.7s" → h=2, m=5, s=6.7?

Wait, but in the given example, it's written as 's.' followed by two digits. So perhaps the input is always formatted
with exactly two digits after .s?

But maybe more flexible.

So code can handle any fractional part.

In Python:

def parse_time(time_str):
    parts = time_str.split('h')
    h = float(parts[0])
    remaining = parts[1]

    parts_m = remaining.split('m')
    m = float(parts_m[0])
    remaining = parts_m[1]

    parts_s = remaining.split('s.')
    s = float(parts_s[0])
    if len(parts_s) > 1:
        fractional = float('.' + parts_s[1])
        s += fractional
    return h * 3600 + m * 60 + s

Wait, but for "45s.78", parts_s would be ["45", "78"], so fractional is 0.78.

Yes.

Testing this function:

For "01h30m45s.78" → h=1, m=30, s=45 + 0.78 = 45.78

Total seconds: 1*3600 +30*60 +45.78 = 3600+1800+45.78= 5445.78.

Another test case:

"2h5m6s.7" → h=2, m=5, s=6.7

Total seconds: 2*3600 +5*60 +6.7 = 7200+300+6.7=7506.7.

Another case:

"1h2m3s" → h=1, m=2, s=3 → total=3600+120+3=3723.

Another edge case: "0h0m0s" → 0 seconds.

Now, for a time like "24h0m0s", that's 86400 seconds. But in reality, times don't usually go beyond 24h, but perhaps
the code can handle it as is.

Now, once we have both total_seconds_start and total_seconds_end, compute difference = end - start.

But if end < start, then difference would be negative. So to get a positive duration, perhaps add 86400 to make it
within 24h?

Alternatively, the problem may not consider that case, but perhaps in code, handle both cases.

But let's proceed with the calculation as is.

Now, convert the difference into hh:mm:ss.ss format.

So:

difference = total_end - total_start

if difference < 0: difference += 86400 (assuming we want a positive duration within 24h)

Then compute hours, minutes, seconds.

In Python:

def format_duration(duration):
    # handle negative durations by adding 86400
    if duration < 0:
        duration += 86400
    hours = int(duration // 3600)
    remaining = duration % 3600
    minutes = int(remaining // 60)
    seconds = remaining % 60
    # format with leading zeros as needed, but the problem may not specify
    return f"{hours:02d}h{minutes:02d}m{seconds:06.3f}s"

Wait, wait.

But in the given example, it's ".78", which is two decimal places for hundredths of a second. So perhaps we need to
format seconds with exactly two decimal digits.

So adjust:

seconds = remaining % 60

formatted_seconds = f"{seconds:.2f}"

But when formatting, if the fractional part has trailing zeros (e.g., 45.78 vs 45.00), they should be shown.

Thus, in code:

def format_duration(duration):
    # handle negative durations by adding 86400
    if duration < 0:
        duration += 86400
    hours = int(duration // 3600)
    remaining = duration % 3600
    minutes = int(remaining // 60)
    seconds = remaining % 60
    # format with leading zeros and two decimal places for seconds
    return f"{hours:02d}h{minutes:02d}m{seconds:05.2f}s"

Wait, but wait:

In the given example, "01h30m45s.78" has 45.78s.

So when we calculate the duration between two times, say start and end, if their difference is positive, then it's end
- start. But in code, perhaps need to handle cases where start is after end (same day or next day).

But the problem says "calculate sexadesimal time between two dates", so I think we can assume that the function takes
two time strings (in sexadecimal format) and returns the duration between them as a positive time.

Wait, actually, no. The user may input times from different days, but in the context of the problem, perhaps it's
better to compute the exact difference, considering wrap-around at 24h.

But I think for this purpose, we can proceed by assuming that the function takes two sexadesimal times and returns
their duration as a positive value within 24h.

Alternatively, if the difference is negative, add 86400 to get the positive equivalent (since 86400 seconds = 24h).

Thus, in code:

start_time = parse_time(start_str)
end_time = parse_time(end_str)

difference = end_time - start_time

if difference < 0:
    difference += 86400

Then format the difference.

Testing with example: suppose we have two times, t1 and t2.

t1 = "01h30m45s.78" → 5445.78 sec
t2 = "02h00m00s" → 7200 sec

difference is 7200 - 5445.78 = 1754.22 sec.

Which would be:

hours = 0, since 1754 < 3600.

minutes = 29 (since 29*60=1740), remaining seconds: 14.22.

So formatted as "00h29m14.22s".

Another test case:

t1 = "23h59m59.98s"
t2 = "00h00m00.02s"

difference is (0.02 - 86399.98) = negative, so add 86400: 0.04 sec.

formatted as "00h00m00.04s".

Thus, the code seems to handle that.

But let's see another example:

t1 is "23h59m59.78s" → total seconds = 23*3600 +59*60 +59.78 = 86399.78

t2 is "00h00m00.22s" → 0.22 sec.

difference: 0.22 - 86399.78 = -86399.56, add 86400 to get 0.44 sec.

formatted as "00h00m00.44s".

Thus, the code seems correct.

Now, let's think about parsing and formatting:

Parsing function: need to split on 'h', 'm', 's' separators.

For example, given a string like "12h34m56.78s", we can split into hours, minutes, seconds.

But in code, the parse_time function needs to handle this.

Similarly for formatting: when reconstructing, use leading zeros as needed.

Thus, the plan is:

- Write a helper function parse_sexagesimal(time_str) that converts a time string like "01h30m45s.78" into total
seconds.

But wait, note that in the given example, it's ".78", which is 78 hundredths of a second. So when parsing, we need to
handle fractions after 's'.

Thus:

def parse_sexagesimal(time_str):
    # split into parts
    parts = time_str.split('h')
    hours = float(parts[0])
    remaining = parts[1]

    parts = remaining.split('m')
    minutes = float(parts[0])
    remaining = parts[1]

    parts = remaining.split('s')
    seconds = float(parts[0])

    # convert to total seconds
    total_seconds = hours * 3600 + minutes * 60 + seconds
    return total_seconds

Wait, but this may have issues with strings that don't have all parts.

For example:

What if time_str is "12h" → implies 0 minutes and 0 seconds.

Or "12m34s.56" → 0 hours, 12 minutes, 34.56 seconds.

Thus, in the parse function, we need to handle cases where some parts may be missing.

Alternatively, perhaps split using multiple separators.

But let's consider a more robust way:

Split on 'h', 'm', and 's' and process accordingly.

Another approach is to use regular expressions to extract hours, minutes, seconds.

So for example, the pattern could be something like (\d+)h(\d+)m(\d+\.\d+)s

But perhaps allowing optional parts.

Alternatively, using a regex that captures each component:

Something like ^(\d{1,2})h(\d{1,2})m([\d.]+)s$.

Wait, but the time could also have only hours, or hours and minutes.

Thus, perhaps the regex can capture optional groups.

But let's test this idea.

For example:

- "01h30m45s.78" → matches h, m, s components.
- "2h" → matches h component, others are zero.
- "3m45s" → matches only m and s?
No, because the regex expects h to be present.

Hmm, maybe better to write a function that tries different splits.

Alternatively, split on 'h', then split the remaining on 'm', etc., as I thought before.

So, for example:

def parse_sexagesimal(time_str):
    # Split into hours, minutes, seconds
    if 'h' in time_str:
        h_part, rest = time_str.split('h', 1)
        hours = float(h_part)
    else:
        hours = 0.0
        rest = time_str

    if 'm' in rest:
        m_part, s_part = rest.split('m', 1)
        minutes = float(m_part)
    else:
        minutes = 0.0
        s_part = rest

    if 's' in s_part:
        seconds = float(s_part[:-1])
    else:
        seconds = float(s_part)  # assuming that if no 's', it's part of the current unit?

    total_seconds = hours * 3600 + minutes * 60 + seconds
    return total_seconds

Wait, but this may not handle all cases correctly. For example:

- "12h" → h_part is '12', rest is empty → then no m or s.
But in the code above, after splitting on 'h', rest becomes ''.

Then, 'm' in rest? No, so minutes = 0, and s_part is ''. Then 's' not in s_part → seconds = 0.0?

Wait, but in the else clause, it's unclear what to do if s_part is empty.

Alternatively, perhaps it's better to split each part step by step:

def parse_sexagesimal(time_str):
    parts = time_str.split('h')
    hours = float(parts[0]) if len(parts) > 0 else 0.0
    remaining = parts[1] if len(parts) > 1 else ''

    parts = remaining.split('m')
    minutes = float(parts[0]) if len(parts) > 0 else 0.0
    remaining = parts[1] if len(parts) > 1 else ''

    parts = remaining.split('s')
    seconds = float(parts[0]) if len(parts) > 0 else 0.0

    total_seconds = hours * 3600 + minutes * 60 + seconds
    return total_seconds

This seems better.

Testing:

- "12h34m56.78s" → parts after h: ['34m56.78', ...], then split on 'm' gives ['34', '56.78s'], then split on 's' gives
['56.78', ...] → seconds = 56.78.
- "12h" → remaining after h is '' → minutes and seconds are zero.
- "30m45s" → parts after h: len(parts) is 1, so hours=0.0, remaining='30m45s' → split on 'm' gives ['30', '45s'], then
split on 's' gives ['45'] → seconds =45.
- "45s" → parts after h: len(parts) 1, so hours=0.0, remaining='45s' → split on 'm' (no), minutes=0, remaining='45s' →
split on 's' gives ['45'] → seconds=45.
- "2h30" → Wait, no 'm' or 's'? This would be a problem because it's ambiguous whether 30 is minutes or seconds.

But perhaps in the context of this function, if a part is just numbers without 'm' or 's', we can assume they are in
hours? Or maybe not. But according to standard time notation, "2h30" could be interpreted as 2 hours and 30 minutes,
but how would the parser know?

In our case, perhaps it's better to enforce that each component is properly labeled with 'h', 'm', or 's'. So if
someone writes "2h30", maybe we can assume 30 seconds? Or 30 minutes?

Alternatively, we can consider "2h30" as 2 hours and 30 minutes.

But without the 'm' or 's', it's ambiguous. Thus, perhaps the function should raise an error if such cases occur. But
that may complicate things.

Alternatively, in our code, after splitting on 'h', the remaining can be further split into 'm' and 's'. So for "2h30",
we have:

- hours = 2.0
- remaining is '30'
- then split on 'm': parts is ['30'], so minutes = 30.0, remaining is ''
- then split on 's': parts is [], seconds=0.0

Thus total_seconds is 2 * 3600 + 30 *60 + 0 → correct.

Similarly, "30m45" would be parsed as minutes=30 and seconds=45, which may not be intended if it's supposed to be 45
minutes. But without 's', perhaps the function assumes that 45 is in seconds. So that could lead to confusion.

Thus, for robustness, we should probably require all components to have their respective labels.

But given that the problem statement uses "01h30m45s.78", which includes all labels, maybe it's safe to assume that the
input strings are well-formed with 'h', 'm', and 's' as needed.

Thus, proceeding under this assumption, our parse function should work.

Now, for formatting:

Given a total number of seconds, we need to convert back into hours, minutes, and seconds, then format into the string
with leading zeros where necessary.
 
Code:
So for example, given 12345.67 seconds → compute hours, mins, secs.

def format_sexagesimal(total_seconds):
    hours = int(total_seconds // 3600)
    remaining = total_seconds % 3600
    minutes = int(remaining // 60)
    seconds = remaining % 60

    # handle fractional part in seconds
    sec_int = int(seconds)
    sec_frac = round((seconds - sec_int) * 100, 2)  # to get hundredths of a second?

    # format with leading zeros
    hours_str = f"{hours:02d}"
    mins_str = f"{minutes:02d}"
    if sec_frac == 0:
        secs_str = f"{sec_int:06.2f}"  # e.g., '45.00' or '30.00'
    else:
        secs_str = f"{seconds:06.2f}"  # includes fractional part

    return f"{hours_str}h{mins_str}m{secs_str}s"

Wait, but when total_seconds is not an integer? For example, if it's 3615.5 seconds → 1h0m15.5s.

Testing the code:

total_seconds = 3615.5

hours = 1
remaining = 15.5
minutes = 0
seconds = 15.5

sec_int=15, sec_frac=0.5 → round(0.5*100)=50. So sec_frac is 50.

Thus secs_str would be '15.50'?

But in the code above:

if sec_frac ==0: no. Then else case: f"{seconds:06.2f}" which for seconds=15.5 → 15.50.

So the output is "01h00m15.50s".

Which seems correct.

Another test case: total_seconds = 30 → 0h0m30s → formatted as "00h00m30.00s"?

Wait, but in this code:

seconds = remaining %60 → 30

sec_int=30, sec_frac=0.

Thus, secs_str would be f"{30:06.2f}" which is '30.00'.

But perhaps the user doesn't want to show .00 when it's zero.

Hmm, but the problem statement example includes ".78" in seconds, so fractional parts are allowed and should be shown.
So for integral seconds, showing .00 is acceptable.

Thus, the format seems okay.

Wait, in code:

If (seconds - sec_int) == 0 → then show as integer with .00? Or perhaps display without decimal?

But according to the problem statement's example, ".78" is included. So for integral seconds, it should still include
two decimal places.

Thus, the current code seems correct.

Another test case: total_seconds = 3661 → which is 1h1m1s.

hours =1

remaining=61

minutes=1

seconds=1

sec_frac=0. So secs_str would be "01.00".

Thus, formatted as "01h01m01.00s". Which is correct.

Another test case: 86400 seconds → exactly 24 hours. Formatted as "24h00m00.00s".

Wait, but in our function:

hours_str is f"{hours:02d}" which for 24 would be '24' correctly.

Thus, the function should handle that.

Now, given all this, the plan is:

1. Parse the input string into hours, minutes, seconds with possible fractional parts.
2. Convert each part to total seconds (as a float).
3. Sum all the converted values to get the total duration in seconds.
4. Format the total seconds back into the sexagesimal format.

But wait: step 3 says "sum all the converted values", but actually, it's better to convert hours and minutes into
seconds, add to the existing seconds, then sum everything as a single number of seconds (as a float). Then, when
formatting, split that total into hours, mins, secs.

Yes, exactly. So for each input component:

- For "hh", multiply by 3600.
- For "mm", multiply by 60.
- For "ss.ss", just add as is.

Thus, the code would be:

Read each part as hh, mm, ss with possible fractional parts.

But in our function, we can extract them via splitting on 'h', 'm', 's'.

Wait: but perhaps a better way is to split the string into parts using 'h', 'm', and 's' as delimiters.

Alternatively, use regular expressions to parse the components.

Given that the input format is "hh:mm:ss[.ff]" or similar?

Wait no: in our case, it's "01h30m45s.78".

Thus, we can split on 'h', 'm', and 's'.

So for example:

input_str = "01h30m45s.78"

split by 'h' → ['01', '30m45s.78']

Then take the first part as hours.

The remaining string is '30m45s.78'.

Split this into parts using 'm' and 's':

Wait, perhaps we can use multiple splits.

Alternatively, split on all non-digit characters except '.'.

But that might get complicated.

Perhaps a better approach: find all the numbers in the string.

For example:

import re

numbers = list(map(float, re.findall(r'\d+\.?\d*', input_str)))

This would extract all numbers as floats. So for "01h30m45s.78", it would give [1.0, 30.0, 45.78].

But we need to know which is hours, minutes, seconds.

Yes: the first number is hours, second is minutes, third is seconds (including fractional parts).

Thus:

def parse_sexagesimal(s):
    # Extract all numbers in order
    numbers = re.findall(r'\d+\.?\d*', s)
    if len(numbers) != 3:
        raise ValueError("Invalid format")
    hours = float(numbers[0])
    minutes = float(numbers[1])
    seconds = float(numbers[2])
    return hours, minutes, seconds

Then compute total_seconds as:

total = hours * 3600 + minutes * 60 + seconds.

Yes, that makes sense.

So the code steps are:

- Read input string.
- Use regular expressions to extract three numbers: hh, mm, ss (with possible decimal parts).
- Convert each to float, then calculate total_seconds as described.
- Then convert total_seconds back into sexagesimal format using the earlier function.

But wait: What if the seconds part has more than two decimal digits?

In our example, 45s.78 is fine. But what about, say, 123.456? Should we handle that? The problem statement allows
fractional parts, but does not specify precision. So perhaps just treat all decimals as they are.

But in the output, we format to two decimal places for seconds.

So, the function should accept any number of decimal digits in input, and output with exactly two decimal digits.

Thus, steps:

Read the string, extract hh, mm, ss (including fractions).

Compute total_seconds = hh*3600 + mm*60 + ss.

Then format as sexagesimal with hours, minutes as integers, seconds as float rounded to two decimals.

But in the code I wrote earlier, when formatting, it's possible that adding up could cause carryover from seconds to
minutes and so on. For example, 30s.78 is okay, but if total_seconds is 61.5, then should be converted into 1m1.5s.

Wait no: in the current approach, when you split the input into hh, mm, ss, it's a fixed structure. So for each
sexagesimal string, it's always hh hours, mm minutes, ss seconds. Thus, when adding them up, total_seconds is computed
correctly as hh*3600 + mm*60 + ss.

But if you have another string where the seconds are over 60, like "00h01m61.5s", then the code would parse this as
hours=0, minutes=1, seconds=61.5 → total_seconds = 0*3600 + 1*60 +61.5 = 60+61.5=121.5 seconds.

But when formatting back, it will show as 0h02m1.5s (since 121.5/60 = 2 minutes and 1.5 seconds). So the code
automatically normalizes overflows in seconds to minutes and so on.

Thus, our code can handle inputs where mm or ss are >=60.

So for example:

Input: "00h01m61.5s"

Parses into hh=0, mm=1, ss=61.5 → total_seconds = 0 + (1*60) +61.5= 60+61.5=121.5 s.

When formatting back: hours=0, minutes=2, seconds=1.5 → output "00h02m01.50s".

Thus, the code correctly handles any overflows in input parts.

Similarly for other cases.

Therefore, I think this approach is correct.

Now, putting it all together:

Implement a function that reads a sexagesimal string (like '01h30m45s.78'), parses into hh, mm, ss with possible
fractions, computes the total in seconds, then converts back to sexagesimal format with hours, minutes as integers and
seconds as two decimal places.

Thus, code:

import re

def sexagesimal_to_total(s):
    numbers = re.findall(r'\d+\.?\d*', s)
    if len(numbers) !=3:
        raise ValueError("Invalid format")
    hh = float(numbers[0])
    mm = float(numbers[1])
    ss = float(numbers[2])
    return hh*3600 + mm*60 + ss

def total_to_sexagesimal(total_seconds):
    # Extract hours
    hours = int(total_seconds // 3600)
    remaining = total_seconds % 3600
    minutes = int(remaining // 60)
    seconds = remaining % 60
    # Round seconds to two decimal places
    seconds = round(seconds, 2)
    # Handle potential rounding issues (e.g., 59.99999999 becomes 60.0)
    if seconds >= 60:
        minutes += 1
        seconds -= 60
        if minutes >=60:
            hours +=1
            minutes -=60
    return f"{hours:02d}h{minutes:02d}m{seconds:05.2f}s"

def calculate_total(s):
    total = sexagesimal_to_total(s)
    return total_to_sexagesimal(total)

Testing the example given:

Input: '1h30m45s'

sexagesimal_to_total returns 1*3600 +30*60+45=3600+1800+45=5445 seconds.

total_to_sexagesimal(5445) would be:

hours = 5445//3600 =1, remaining =5445%3600=1845 s.

minutes = 1845//60=30, remaining seconds=45. So output is '01h30m45.00s'.

Another test case: Input "0h0m61.5s"

sexagesimal_to_total gives 0 +0 +61.5=61.5 s.

total_to_sexagesimal(61.5):

hours=0, remaining=61.5

minutes =61.5//60=1 → remaining=1.5.

Thus output is '00h01m01.50s'.

Another test case: "24h30m120s"

sexagesimal_to_total:

24*3600 + 30*60 +120 = 86400+1800+120= 88320 seconds.

total_to_sexagesimal(88320):

hours=88320//3600=24, remaining=88320%3600= 88320-24*3600=88320-86400=1920 s.

minutes=1920//60=32, seconds=0. So output '24h32m00.00s'.

Wait, but 1920 seconds is 32 minutes exactly.

Thus, that's correct.

Another test case with fractions:

Input: "0h59m59.999999s"

total_seconds=59*60 +59.999999 = 3540 +59.999999≈3599.999999 s.

total_to_sexagesimal(3599.999999):

hours=0, remaining=3599.999999 → minutes =3599.999999//60=59, seconds=3599.999999%60≈59.999999.

Rounded to two decimals: 59.999999 ≈60.0 → which is >=60, so minutes +=1 (becomes 60), seconds -=60 → -0.000... Wait,
that can't be right.

Wait wait:

total_seconds=3599.999999 s = 59*60 + 59.999999 → which is almost 1 hour minus a tiny bit.

But when formatting:

hours = 3599.999999 //3600=0

remaining =3599.999999 s.

minutes= remaining//60 →3599.999999 /60 is ~59.9999999, so int(59.999999) is 59.

seconds = remaining%60 →3599.999999 -59*60= 3599.999999-3540=59.999999 s.

Rounded to two decimals:59.999999 →60.0, which is equal to 60. So we have seconds >=60.

So in the function:

if seconds >=60:
    minutes +=1
    seconds -=60
    if minutes>=60:
        hours +=1
        minutes -=60

But here, after adding 1 minute and subtracting 60 from seconds, seconds becomes -0. So that's not correct.

Wait wait: in the function, after calculating:

seconds = remaining %60 →59.999999 s.

Then rounded to two decimals: 60.0? Wait no: 59.999999 is approximately 60 when rounded to two decimals?

No: 59.999999 is 59.999999, which would be 60.0 if we round up after 2 decimal places? Wait no:

Wait 59.999999 is very close to 60 but less than 60.

Rounded to two decimals: it's 60.0 when rounded? Because 59.995 would be rounded to 60.0, but 59.994999 would be 59.99.

Wait wait:

In Python, round(59.999999,2) is 60.0?

Let me test in Python shell:

>>> round(59.999999,2)
60.0

Yes, because the third decimal is a 9, which causes it to round up.

So seconds would be 60.0 after rounding. So we have:

seconds =60.0 → >=60 → minutes +=1, seconds -=60=0.0.

But then, since minutes was initially 59, becomes 60. Then check if minutes >=60: yes. So hours +=1 (from 0 to1), and
minutes becomes 0.

Thus, the output is '01h00m00.00s'.

Which makes sense because 3599.999999 seconds is almost exactly 1 hour minus a tiny fraction of a second.

But when rounded, it becomes 1 hour.

So the function handles that correctly.

Another test case: "1h2m3.456789s"

Total_seconds=3600 + 120 +3.456789=3723.456789 s.

total_to_sexagesimal(3723.456789):

hours =3723//3600=1, remaining=123.456789 s.

minutes=123.456789//60=2, seconds=123.456789%60≈3.456789.

Rounded to two decimals: 3.46.

So output is '01h02m03.46s'.

Another test case with negative time? Well, the problem states "calculate sexagesimal" but I don't think the function
handles negative times since we are dealing with durations.

But in our functions, if someone passes a negative total, it would have negative hours, which is not handled.

But given that the problem statement may assume positive durations, perhaps this isn't an issue.

Thus, the code seems to handle the conversions correctly.
</think>

To solve this problem, we need to convert a given time duration from sexagesimal format (hours, minutes, seconds) into
total seconds and then back into a formatted sexagesimal string. The conversion must handle rounding of seconds to two
decimal places and account for any overflow that may occur due to rounding.

### Approach

1. **Convert Sexagesimal to Total Seconds**:
   - Extract hours, minutes, and seconds from the input string.
   - Convert each component into total seconds by using the formula: `total_seconds = hours * 3600 + minutes * 60 +
seconds`.

2. **Convert Total Seconds Back to Sexagesimal**:
   - Calculate the number of hours by dividing the total seconds by 3600.
   - Compute the remaining seconds after extracting hours and then calculate the number of minutes by dividing these
remaining seconds by 60.
   - The leftover seconds are rounded to two decimal places. If rounding causes the seconds to reach or exceed 60,
adjust the minutes accordingly. Similarly, if adjusting minutes causes them to reach or exceed 60, adjust the hours.

### Solution Code

```python
def sexagesimal_to_seconds(sex_str):
    """
    Converts a sexagesimal string (e.g., '1h2m3.45s') into total seconds.

    Parameters:
        sex_str (str): The time duration in sexagesimal format.

    Returns:
        float: The total number of seconds.
    """
    # Split the string into parts
    parts = []
    current = ''
    for char in sex_str:
        if char.isdigit() or char == '.':
            current += char
        else:
            if current != '':
                parts.append(current)
                current = ''
    if current != '':
        parts.append(current)

    # Determine which parts are hours, minutes, seconds
    total_seconds = 0.0
    for i in range(len(parts)):
        part = parts
        unit = sex_str[sex_str.index(part) + len(part)]
        if unit == 'h':
            total_seconds += float(part) * 3600
        elif unit == 'm':
            total_seconds += float(part) * 60
        elif unit == 's':
            total_seconds += float(part)
    return total_seconds

def seconds_to_sexagesimal(total_sec):
    """
    Converts total seconds into a formatted sexagesimal string.

    Parameters:
        total_sec (float): The total number of seconds.

    Returns:
        str: Time duration in the format 'XhYmZ.ZZs'.
    """
    hours = int(total_sec // 3600)
    remaining = total_sec % 3600
    minutes = int(remaining // 60)
    seconds = remaining % 60

    # Round to two decimal places
    rounded_seconds = round(seconds, 2)

    # Adjust for rounding that may cause overflow
    if rounded_seconds >= 60:
        carry_minutes = int(rounded_seconds // 60)
        minutes += carry_minutes
        rounded_seconds -= carry_minutes * 60

    if minutes >= 60:
        carry_hours = int(minutes // 60)
        hours += carry_hours
        minutes %= 60

    # Format the string
    return f"{hours}h{minutes}m{rounded_seconds:.2f}s"

# Example usage
sex_str = "1h2m3.45s"
total_sec = sexagesimal_to_seconds(sex_str)
print(f"Total seconds: {total_sec}")
formatted_sex = seconds_to_sexagesimal(total_sec)
print(f"Formatted sexagesimal: {formatted_sex}")
```

### Explanation

- **Conversion from Sexagesimal to Seconds**: The function `sexagesimal_to_seconds` parses the input string, extracts
each component (hours, minutes, seconds), and converts them into total seconds. This is done by breaking down the
string character by character and summing up the contributions of each part.

- **Conversion from Seconds to Sexagesimal**: The function `seconds_to_sexagesimal` takes the total seconds and
converts it back into hours, minutes, and seconds. It handles potential overflow issues due to rounding by adjusting
the minutes and hours as necessary before formatting the result into a string with two decimal places for seconds.

This approach ensures accurate conversion between sexagesimal format and total seconds while properly handling any
overflow that may occur during the process.
 
I am bringing back these thread regarding LLMs, because has anyone tried running the latest models with ollama????

I am getting an error with GPT-OSS and the newer version of Deepseek

Code:
root@Secure_Ollama:/ # ollama run deepseek-r1:8b
Error: llama runner process has terminated: this model is not supported by your version of Ollama. You may need to upgrade

Code:
root@Secure_Ollama:/ # freebsd-version -ru
14.3-RELEASE
14.3-RELEASE-p3
Is there a new update I need to compile directly, or I need to do it via portree? Does anyone have a workaround....
 
A list of my models :
Code:
codegeex4:9b
codegemma:2b
codegemma:7b
codellama:13b
codellama:7b
codeqwen:7b
deepseek-coder:1.3b
deepseek-coder:6.7b
deepseek-r1:1.5b
dolphincoder:15b
dolphincoder:7b
dolphin-mistral:7b
dolphin-phi:2.7b
llama2-uncensored:7b
llama3.2:1b
llama3.2:3b
mathstral:7b
meditron:7b
medllama2:7b
mistral:7b
mistral:7b-instruct
mistral-openorca:7b
mistral-openorca:latest
nuextract:3.8b
ollama.com/cniongolo/biomistral:latest
ollama.com/f0rodo/bio-mistral-dare:latest
openchat:7b
orca-mini:3b
orca-mini:7b
phi3:14b
phi3:3.8b
phi4:14b
qwen2.5-coder:0.5b
qwen2.5-coder:1.5b
qwen2.5-coder:3b
qwen3:4b
sqlcoder:15b
sqlcoder:7b
starcoder:1b
starcoder2:15b
starcoder2:3b
starcoder2:7b
starcoder:3b
starcoder:7b
tinydolphin:1.1b
yi-coder:1.5b
zephyr:7b
 
A list of my models :
Code:
codegeex4:9b
codegemma:2b
codegemma:7b
codellama:13b
codellama:7b
codeqwen:7b
deepseek-coder:1.3b
deepseek-coder:6.7b
deepseek-r1:1.5b
dolphincoder:15b
dolphincoder:7b
dolphin-mistral:7b
dolphin-phi:2.7b
llama2-uncensored:7b
llama3.2:1b
llama3.2:3b
mathstral:7b
meditron:7b
medllama2:7b
mistral:7b
mistral:7b-instruct
mistral-openorca:7b
mistral-openorca:latest
nuextract:3.8b
ollama.com/cniongolo/biomistral:latest
ollama.com/f0rodo/bio-mistral-dare:latest
openchat:7b
orca-mini:3b
orca-mini:7b
phi3:14b
phi3:3.8b
phi4:14b
qwen2.5-coder:0.5b
qwen2.5-coder:1.5b
qwen2.5-coder:3b
qwen3:4b
sqlcoder:15b
sqlcoder:7b
starcoder:1b
starcoder2:15b
starcoder2:3b
starcoder2:7b
starcoder:3b
starcoder:7b
tinydolphin:1.1b
yi-coder:1.5b
zephyr:7b
Okay cool, how did you install ollama? Did you do it through port tree? Or did you do pkg install ollama?

Because the
Code:
pkg ollama-0.3.6_5
is giving that error on some models and others LLM like 80% you have I can use.

Thanks Alain De Vos
 
Back
Top