Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #67 from inickt/nick/timezones
Browse files Browse the repository at this point in the history
Fix timezone bug preventing master URL from being created
  • Loading branch information
inickt authored Jan 6, 2020
2 parents 88e48ee + 1d12143 commit e95e16b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions LazyManCore/Managers/FeedManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public class FeedManager: FeedManagerType {
- returns: A URL of this Feed's master playlist, or nil if it cannot be loaded
*/
private func getMasterURL(league: League, cdn: CDN, playbackID: Int, date: Date) -> URL? {
// swiftlint:disable:next line_length
let masterURLSource = "http://nhl.freegamez.ga/getM3U8.php?league=\(league.rawValue)&date=\(DateUtils.convertToYYYYMMDD(from: date))&id=\(playbackID)&cdn=\(cdn.rawValue)"
let dateString = DateUtils.convertToYYYYMMDD(from: date, timeZone: TimeZone(identifier: "America/Los_Angeles")!)
let masterURLSource = "http://nhl.freegamez.ga/getM3U8.php?league=\(league.rawValue)&date=\(dateString)&id=\(playbackID)&cdn=\(cdn.rawValue)"

if let contents = try? String(contentsOf: URL(string: masterURLSource)!) {
return URL(string: contents)
Expand Down
4 changes: 2 additions & 2 deletions LazyManCore/Util/DateUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ enum DateUtils {

// MARK: - Public Helpers

// TODO: Make sure correct for timezones/day boundries/etc!!!
static func convertToYYYYMMDD(from date: Date) -> String {
static func convertToYYYYMMDD(from date: Date, timeZone: TimeZone = TimeZone.current) -> String {
yyyymmddFormatter.timeZone = timeZone
return self.yyyymmddFormatter.string(from: date)
}

Expand Down

0 comments on commit e95e16b

Please sign in to comment.