有没有办法通过Boost获得区域时间格式?

时间:2018-05-22 08:44:04

标签: c++ boost boost-date-time

当我试图在我的标题中提问时,我说的是区域时间格式。我有一个可以显示时间/日期的应用程序,但是从美国用户那里我得到的问题是我为什么要显示这样的时间: 21:30 而不是这个:晚上9:30。我将日期显示为 22.05.2018 而非 05.22.2018 的日期相同。

所以我的问题是:有没有办法获得时区标志或位置,甚至已经格式化的时间,以便我可以显示不同地区的时间/日期不同?

1 个答案:

答案 0 :(得分:1)

Boost Locale

#include <iostream>
using namespace std;

int main(){
    double A[10][10], alpha[10][10], B[10], betha[10], x[10][100], sum[10];
    int i, j, n, k, kmax;
    cout << "insert number of equations \n";
    cin >> n;
    cout << "insert LHS of equations (a11,a12,...,ann)\n";
    for (i = 1; i <= n; i++){
        for (j = 1; j <= n; j++){
            cin >> A[i][j];
        }
    }
    cout << "A=\n";
    for (i = 1; i <= n; i++){
        for (j = 1; j <= n; j++){
            cout << A[i][j] << "\t\t";
        }
        cout << "\n\n";
    }
    cout << "alpha=\n";
    for (i = 1; i <= n; i++){
        for (j = 1; j <= n; j++){
            if (i == j){
                alpha[i][j] = 0;
            }
            else{
                alpha[i][j] = -A[i][j] / A[i][i];
            }
        }
    }
    for (i = 1; i <= n; i++){
        for (j = 1; j <= n; j++){
            cout << alpha[i][j] << "\t\t";
        }
        cout << "\n\n";
    }
    cout << "insert RHS of equations";
    for (i = 1; i <= n; i++){
        cin >> B[i];
    }
    cout << "\nbetha=\n";
    for (i = 1; i <= n; i++){
        betha[i] = B[i] / A[i][i];
        cout << betha[i] << endl;
    }
    cout << "Enter the number of repetitions." << endl;
    cin >> kmax;
    k = 0;
    for (i = 1; i <= n; i++){
        sum[i] = 0;
        x[i][k] = betha[i];    //initial values 
    }
    for (k = 0; k <= kmax; k++){
        for (i = 1; i <= n; i++){
            for (j = 1; j <= n; j++){
                sum[i] += alpha[i][j] * x[j][k];
            }
            x[i][k] = betha[i] + sum[i];
            sum[i] = 0; 
        }
    }
    cout << "answers:\n\n";
    for (i = 1; i <= n; i++){
        cout << x[i][kmax] << endl;
    }
    return 0;
}

从字符串返回解析日期并添加时区