package test

import (
	"fmt"
	ultipa "github.com/ultipa/ultipa-go-sdk/rpc"
	"github.com/ultipa/ultipa-go-sdk/sdk/configuration"
	"github.com/ultipa/ultipa-go-sdk/sdk/utils"
	"testing"
)

func TestLocation(t *testing.T) {
	config1 := &configuration.RequestConfig{
		TimezoneOffset: 3600,
	}
	location1 := utils.GetLocationFromConfig(config1)
	timestamp1, _ := utils.StringAsInterface("1970-01-01 00:00:00", ultipa.PropertyType_TIMESTAMP, location1)
	t.Log(timestamp1)

	config2 := &configuration.RequestConfig{
		Timezone: "+0300",
	}
	location2 := utils.GetLocationFromConfig(config2)
	timestamp2, _ := utils.StringAsInterface("1970-01-01 00:00:00", ultipa.PropertyType_TIMESTAMP, location2)
	t.Log(timestamp2)

	config3 := &configuration.RequestConfig{
		Timezone: "Europe/Paris",
	}
	location3 := utils.GetLocationFromConfig(config3)
	timestamp3, _ := utils.StringAsInterface("2038-01-19 03:14:07", ultipa.PropertyType_TIMESTAMP, location3)
	t.Log(timestamp3)

	config4 := &configuration.RequestConfig{
		Timezone: "Asia/Shanghai",
	}
	location4 := utils.GetLocationFromConfig(config4)
	timestamp4, _ := utils.StringAsInterface("2038-01-19 03:14:07", ultipa.PropertyType_TIMESTAMP, location4)
	t.Log(timestamp4)
}

func TestRemoveLocation(t *testing.T) {
	examples := []string{
		"2006-1-2T15:04:05.000Z0700",
		"2006-1-2T15:04:05.000Z07:00",
		"2006-1-2T15:04:05Z0700",
		"2006-1-2T15:04:05Z07:00",
		"06-1-2T15:04:05.000Z0700",
		"06-1-2T15:04:05.000Z07:00",
		"06-1-2T15:04:05Z0700",
		"06-1-2T15:04:05Z07:00",
		"2006-1-2T15:04:05.000-0700",
		"2006-1-2T15:04:05.000-07:00",
		"2006-1-2T15:04:05-0700",
		"2006-1-2T15:04:05-07:00",
		"2006-1-2T15:04:05",

		"06-1-2T15:04:05.000Z0700",
		"06-1-2T15:04:05.000Z07:00",
		"06-1-2T15:04:05Z0700",
		"06-1-2T15:04:05Z07:00",

		"2006-1-2 15:04:05.000Z0700",
		"2006-1-2 15:04:05.000Z07:00",
		"2006-1-2 15:04:05Z0700",
		"2006-1-2 15:04:05Z07:00",

		"06-1-2 15:04:05.000Z0700",
		"06-1-2 15:04:05.000Z07:00",
		"06-1-2 15:04:05Z0700",
		"06-1-2 15:04:05Z07:00",

		"2006-1-2 15:04:05.000-0700",
		"2006-1-2 15:04:05.000-07:00",
		"2006-1-2 15:04:05-0700",
		"2006-1-2 15:04:05-07:00",
		"2006-1-2 15:04:05 -0700 MST",
		"2006-1-2 15:04:05 MST",

		"06-1-2 15:04:05.000-0700",
		"06-1-2 15:04:05.000-07:00",
		"06-1-2 15:04:05-0700",
		"06-1-2 15:04:05-07:00",

		"2006-1-2 15:04:05.000",
		"2006-1-2 15:04:05",
		"2006-1-2 15:04",
		"2006-1-2 15",
		"2006-1-2",

		"06-1-2 15:04:05.000",
		"06-1-2 15:04:05",
		"06-1-2 15:04",
		"06-1-2 15",
		"06-1-2",

		"2006/1/2T15:04:05.000Z07:00",
		"2006/1/2T15:04:05.000Z0700",
		"2006/1/2T15:04:05Z07:00",
		"2006/1/2T15:04:05Z0700",

		"06/1/2T15:04:05.000Z07:00",
		"06/1/2T15:04:05.000Z0700",
		"06/1/2T15:04:05Z07:00",
		"06/1/2T15:04:05Z0700",

		"2006/1/2T15:04:05.000-07:00",
		"2006/1/2T15:04:05.000-0700",
		"2006/1/2T15:04:05-07:00",
		"2006/1/2T15:04:05-0700",

		"06/1/2T15:04:05.000-07:00",
		"06/1/2T15:04:05.000-0700",
		"06/1/2T15:04:05-07:00",
		"06/1/2T15:04:05-0700",

		"2006/1/2 15:04:05.000Z07:00",
		"2006/1/2 15:04:05.000Z0700",
		"2006/1/2 15:04:05Z07:00",
		"2006/1/2 15:04:05Z0700",

		"06/1/2 15:04:05.000Z07:00",
		"06/1/2 15:04:05.000Z0700",
		"06/1/2 15:04:05Z07:00",
		"06/1/2 15:04:05Z0700",

		"2006/1/2 15:04:05.000-07:00",
		"2006/1/2 15:04:05.000-0700",
		"2006/1/2 15:04:05-07:00",
		"2006/1/2 15:04:05-0700",

		"06/1/2 15:04:05.000-07:00",
		"06/1/2 15:04:05.000-0700",
		"06/1/2 15:04:05-07:00",
		"06/1/2 15:04:05-0700",

		"2006/1/2 15:04:05.000",
		"2006/1/2 15:04:05",
		"2006/1/2 15:04",
		"2006/1/2 15",
		"2006/1/2",

		"06/1/2 15:04:05.000",
		"06/1/2 15:04:05",
		"06/1/2 15:04",
		"06/1/2 15",
		"06/1/2",

		"2006-01-02T15:04:05.000Z07:00",
		"2006-01-02T15:04:05.000Z0700",
		"2006-01-02T15:04:05Z07:00",
		"2006-01-02T15:04:05Z0700",

		"06-01-02T15:04:05.000Z07:00",
		"06-01-02T15:04:05.000Z0700",
		"06-01-02T15:04:05Z07:00",
		"06-01-02T15:04:05Z0700",

		"2006-01-02T15:04:05.000-07:00",
		"2006-01-02T15:04:05.000-0700",
		"2006-01-02T15:04:05-07:00",
		"2006-01-02T15:04:05-0700",

		"06-01-02T15:04:05.000-07:00",
		"06-01-02T15:04:05.000-0700",
		"06-01-02T15:04:05-07:00",
		"06-01-02T15:04:05-0700",

		"2006-01-02 15:04:05.000Z07:00",
		"2006-01-02 15:04:05.000Z0700",
		"2006-01-02 15:04:05Z07:00",
		"2006-01-02 15:04:05Z0700",

		"06-01-02 15:04:05.000Z07:00",
		"06-01-02 15:04:05.000Z0700",
		"06-01-02 15:04:05Z07:00",
		"06-01-02 15:04:05Z0700",

		"2006-01-02 15:04:05.000-07:00",
		"2006-01-02 15:04:05.000-0700",
		"2006-01-02 15:04:05-07:00",
		"2006-01-02 15:04:05-0700",

		"06-01-02 15:04:05.000-07:00",
		"06-01-02 15:04:05.000-0700",
		"06-01-02 15:04:05-07:00",
		"06-01-02 15:04:05-0700",

		"2006-01-02 15:04:05.000",
		"2006010215:04:05.000Z0700",
		"2006010215:04:05.000Z07:00",
		"2006010215:04:05Z0700",
		"2006010215:04:05Z07:00",

		"06-01-02 15:04:05.000",
		"06010215:04:05.000Z0700",
		"06010215:04:05.000Z07:00",
		"06010215:04:05Z0700",
		"06010215:04:05Z07:00",

		"2006010215:04:05.000-0700",
		"2006010215:04:05.000-07:00",
		"2006010215:04:05-0700",
		"2006010215:04:05-07:00",

		"06010215:04:05.000-0700",
		"06010215:04:05.000-07:00",
		"06010215:04:05-0700",
		"06010215:04:05-07:00",

		"2006010215:04:05",
		"2006-01-02 15:04:05",
		"2006-01-02 15:04",
		"2006-01-02 15",
		"2006-01-02",

		"06010215:04:05",
		"06-01-02 15:04:05",
		"06-01-02 15:04",
		"06-01-02 15",
		"06-01-02",
	}

	for _, example := range examples {
		fmt.Printf("Before: %s\n", example)
		fmt.Printf("After:  %s\n", utils.RemoveTimezone(example))
		fmt.Println()
	}
}
