Functions TimezoneInfo.FindSystemTimeZoneById() returns no values in AWs lambda for the provided time zone [duplicate] - timezone

I have deployed my application on AWS Lambda but while getting time zone i am getting this error
'The time zone ID 'Pacific Standard Time' was not found on the local computer.'
How can i add timezones on lambda.
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(userModel.TimeZoneListCode);

In general, if Windows time zones like this don't work:
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
... then you're not running on Windows and either you're not using .NET 6 or higher, or you don't have ICU data available in your environment. Either way, you should be able to use IANA time zones:
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
Alternatively, you can use TimeZoneConverter to work with either form:
TimeZoneInfo tzi = TZConvert.GetTimeZoneInfo("Pacific Standard Time");
or
TimeZoneInfo tzi = TZConvert.GetTimeZoneInfo("America/Los_Angeles");

Related

Overriding Dart's local time zone

Dart's DateTime only supports UTC and "local" time. Is there a way to specify a local time zone when running tests, short of changing the time zone on the machine running the tests (or replacing DateTime with a time-zone-aware library)? See e.g. Java's user.timezone system property.
I think the clock package should be useful.
Run you test inside withClock()
test('clock', () {
withClock(Clock.fixed(DateTime.parse('2002-02-27T14:00:00-0500'), () {
// your test here
});
});

How to do time comparison between client's system time and date time from internet server (actual local time)

I am trying to validate the system time of client’s computer with the actual time (internet time). If for some reason the client’s time settings are not correct or the time and timezone don’t match the local time, I want to notify them to sync the time with their local time in order to use the application. If my question is not clear then this is something that I am trying to mimic, https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Incorrect-System-time-warning-when-starting-an-Autodesk-360-application.html
How can I do this time comparison/validation in dart?
The main question is IMHO what accuracy you need.
You can just query a NTC and report if there is a discrepancy. If the server is synchronized with such a time server, there shouldn't be a problem.
You can also add an API to your server that returns the server time.
Then you read the time from the local system and from the server and check the difference
bool compareTime() {
var serverTime = await getTimeFromServer(); // not yet existing method to fetch the date and time from the server
var clientTime = new DateTime.now().toUtc();
var diff = serverTime.difference(clientTime).abs();
if(diff > const Duration(seconds: 5)) {
print('Time difference too big');
} else {
print('Time is fine');
}
}
Ensure that the time returned from the server is UTC as well, otherwise you're comparing apples with pears.
If you're running server-side, you can shell out to ntpdate -d pool.ntp.org and read the output, parsing the last line. If the time offset is small enough, you're good.
For browser apps, see the StackOverflow at Getting the current GMT world time for a few options.

timezone id to short timezone (pst, pdt, cst, etc)

I use Googles Timezone API to get TimeZoneID and I pass it to the ruby gem TZInfo to get the local time. How can I get the Timezones short name (PST, PDT, EST, etc...) from this info. I tried strftime(%Z) but that returns 'UTC'. This is a ruby on rails app.
TZInfo::Timezone#strftime ought to work:
require "tzinfo"
tz = TZInfo::Timezone.get("America/New_York")
puts tz.strftime("%Z")
If you tried that and it didn't work, that's mysterious.
Alternatively, you can use TZInfo::TimezonePeriod#abbreviation:
tz = TZInfo::Timezone.get('America/New_York')
period = tz.period_for_utc(Time.now.utc)
puts period.abbreviation

Single Sign-on - PingfFederate - How to set the date?

I noticed when PingFederate(PF) sends the date it is off by a day from my Rails app. It appears that the PF date is the one off by a day. For example in the PF SAML response I get:
<saml:Assertion ID="pEaf1kce93SpAxfIpuohOv6QP-T" IssueInstant="2014-05-03T03:15:20.020Z" Version="2.0" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
and
<saml:Conditions NotBefore="2014-05-03T03:10:20.021Z" NotOnOrAfter="2014-05-03T03:20:20.021Z">
whereas in Rails I get
Time.now = 2014-05-02 20:15:19 -0700
which makes me think that I need to set the date in PF. Note that PF is running on the same computer that the Rails app is running on.
Is there a way to set the date in PF?
The time is off as well. Is there a way in PF to set the time too?
SAML assertions are always in UTC. Which is what PingFed is using. Set your Rails application to use UTC as well.
I don't see why you think that the time is off. Your time from Rails is 2015 and -7. That means in UTC, it's tomorrow at 0315 - when it was issued. PingFed is setting an allowance of +/-5 minutes, so the SP should not accept it before 0310 or after 0320.
Your server and PingFed are correct so far...

php 5.2.17 date('T') gives incorrect timezone. Server time+phpinfo time are correct

I am having a bit of a weird issue:
the date function gives timezone=MST
the date function from the centOS prompt gives me EST
the phpinfo() function returns America/New_York
As Plesk was showing America/New_York but centOS was not, Techsupport did something to the
/usr/share/zoneinfo/ files, because they said that somehow the New_York file was showing MST (Mountain Time).
After that operation, centOS time and phpinfo() display EST correctly but the date function still display MST.
Any ideas?
Did you tried date_default_timezone_set()?
Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_WARNING message if using the system settings or the TZ environment variable.

Resources